/** * @param Entity $entity * @param int|string|null|Entity $id * @param null $select * @param bool $lazyLoad * @throws Err */ public function __construct(Entity $entity, $id = null, $select = null, $lazyLoad = self::DEF_LAZY_LOAD) { if (!$entity instanceof Entity) { throw new Err('', Err::E_RECORD_ENTITY_NOT_SET); } $this->entity = $entity; $this->primaryKey = $this->entity->getMainTablePrimaryKey(); $this->primaryKeyAutoIncrement = $this->entity->getMainTableAutoIncrement(); if (empty($select) || !is_array($select)) { $this->entityFields = array_keys($this->entity->getTableFieldsCheck()); } else { $this->entityFields = array(); $arRealTableFields = $this->entity->getTableFields(); foreach ($select as &$field) { if (!array_key_exists($field, $arRealTableFields)) { $this->entityFields[] = $field; } } } $this->MessagePool = $this->entity->getMessagePool(); if (null !== $id) { $this->read($id, $select); } $this->lazyLoad = !!$lazyLoad; }
public static final function __initEntity(Entity $Entity) { $className = get_called_class(); if (!isset(self::$_arDBSimpleEntities[$className])) { if ($Entity instanceof Entity) { self::$_arDBSimpleEntities[$className] = $Entity; self::setMessagePool($Entity->getMessagePool()); } } }