AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.137.168.42
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/main/lib/orm/objectify/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/main/lib/orm/objectify/identitymap.php
<?php
/**
 * Bitrix Framework
 * @package    bitrix
 * @subpackage main
 * @copyright  2001-2018 Bitrix
 */

namespace Bitrix\Main\ORM\Objectify;

use Bitrix\Main\ORM\Entity;

/**
 * Object registry, stores objects in collections.
 *
 * @package    bitrix
 * @subpackage main
 */
class IdentityMap
{
	/** @var Collection[] */
	protected $collections;

	/**
	 * @param $class
	 * @param $primary
	 *
	 * @return EntityObject|null
	 * @throws \Bitrix\Main\ArgumentException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function get($class, $primary)
	{
		$collection = $this->getCollectionByClass($class);
		return $collection->getByPrimary($primary);
	}

	/**
	 * @param EntityObject $object
	 *
	 * @return Collection
	 * @throws \Bitrix\Main\ArgumentException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function put($object)
	{
		$collection = $this->getCollectionByClass(get_class($object));
		$collection[] = $object;

		return $collection;
	}

	/**
	 * @param $class
	 *
	 * @return Collection
	 * @throws \Bitrix\Main\ArgumentException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function getCollectionByClass($class)
	{
		if (empty($this->collections[$class]))
		{
			$normalizedClass = Entity::normalizeName($class);

			if (!empty($this->collections[$normalizedClass]))
			{
				$this->collections[$class] = $this->collections[$normalizedClass];
			}
			else
			{
				if (Entity::has($normalizedClass))
				{
					$entity = Entity::get($normalizedClass);
				}
				else
				{
					/** @var $normalizedClass EntityObject custom object class */
					$entity = Entity::getInstance($normalizedClass::$dataClass);
				}

				$collection = $entity->createCollection();

				$this->collections[$class] = $collection;
				$this->collections[$normalizedClass] = $collection;
			}
		}

		return $this->collections[$class];
	}
}

Anon7 - 2022
AnonSec Team