Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
loader.php
1<?php
9namespace Bitrix\Main\ORM;
10
12
19class Loader
20{
22 protected static $predefinedObjectClass;
23
26
27 public static function autoLoad($class)
28 {
29 // break recursion
30 if (substr($class, -5) == 'Table')
31 {
32 return;
33 }
34
35 if (strpos($class, '\\') === false)
36 {
37 // define global namespace explicitly
38 $class = '\\'.$class;
39 }
40
41 $namespace = substr($class, 0, strrpos($class, '\\') + 1);
42 $className = substr($class, strrpos($class, '\\') + 1);
43
44 if (substr($className, 0, 3) == 'EO_')
45 {
46 $needFor = 'object';
47
48 if ($className == 'EO_NNM_Object')
49 {
50 // entity without name, defined by namespace
51 $entityName = '';
52 }
53 elseif (substr($className, -11) == '_Collection')
54 {
55 $needFor = 'collection';
56 $entityName = substr($className, 3, -11);
57 }
58 else
59 {
60 $entityName = substr($className, 3);
61 }
62
63 $entityName .= 'Table';
64 $entityClass = $namespace.$entityName;
65
66 if (class_exists($entityClass) && is_subclass_of($entityClass, DataManager::class))
67 {
68 ($needFor == 'object')
69 ? Entity::compileObjectClass($entityClass)
70 : Entity::compileCollectionClass($entityClass);
71 }
72 }
73 }
74
75 public static function registerObjectClass($objectClass, $entityClass)
76 {
77 static::$predefinedObjectClass[strtolower(Entity::normalizeName($objectClass))] = $entityClass;
78 }
79
80 public static function registerCollectionClass($collectionClass, $entityClass)
81 {
82 static::$predefinedCollectionClass[strtolower(Entity::normalizeName($collectionClass))] = $entityClass;
83 }
84}
static $predefinedCollectionClass
Definition loader.php:25
static registerObjectClass($objectClass, $entityClass)
Definition loader.php:75
static $predefinedObjectClass
Definition loader.php:22
static registerCollectionClass($collectionClass, $entityClass)
Definition loader.php:80
static autoLoad($class)
Definition loader.php:27