Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
identitymap.php
1<?php
10
12
20{
22 protected $collections;
23
32 public function get($class, $primary)
33 {
34 $collection = $this->getCollectionByClass($class);
35 return $collection->getByPrimary($primary);
36 }
37
45 public function put($object)
46 {
47 $collection = $this->getCollectionByClass(get_class($object));
48 $collection[] = $object;
49
50 return $collection;
51 }
52
60 public function getCollectionByClass($class)
61 {
62 if (empty($this->collections[$class]))
63 {
64 $normalizedClass = Entity::normalizeName($class);
65
66 if (!empty($this->collections[$normalizedClass]))
67 {
68 $this->collections[$class] = $this->collections[$normalizedClass];
69 }
70 else
71 {
72 if (Entity::has($normalizedClass))
73 {
74 $entity = Entity::get($normalizedClass);
75 }
76 else
77 {
79 $entity = Entity::getInstance($normalizedClass::$dataClass);
80 }
81
82 $collection = $entity->createCollection();
83
84 $this->collections[$class] = $collection;
85 $this->collections[$normalizedClass] = $collection;
86 }
87 }
88
89 return $this->collections[$class];
90 }
91}
static normalizeName($entityName)
Definition entity.php:876
static getInstance($entityName)
Definition entity.php:103
static has($entityName)
Definition entity.php:88
static get($entityName)
Definition entity.php:76