Вспомнить пользователя
@return Entity
427701
protected static function remind()
    {
        self::$user = null;
        if (!empty(self::$input['COOKIE']['ID'])){
            $ID = explode('|', self::$input['COOKIE']['ID']);
        }else{
            $ID = '';
        }
        // Период запоминания пользователя
        $duration = empty($ID[0])? 0 : $ID[0]; // не больше месяца (примерно)
        // Хэш пользователя для поиска (авторизации)
        $hash = empty($ID[1]) ? '' : $ID[1];
        // Если есть кука, то ищем пользователя в БД
        if ($hash){
            $result = Data::find(array(
                'from' => self::$config['users-list'],
                'select' => 'children',
                'depth' => 'max',
                'where' => array(
                    array('value', '=', $hash),
//                    array('not','is_link')
                ),
                'key' => false,
                'limit' => array(0, 1),
                'comment' => 'auth user by cookie',
            ), false);
            // Пользователь найден и не истекло время его запоминания
            if (!empty($result)){
                self::$user = $result[0];
            }
        }else{
            $hash = self::get_unique_hash();
        }
        // Новый гость
        if (!self::$user){
            self::$user = Data::create(self::$config['user'], self::$config['users-list']);
            self::$user->value($hash);
            $duration = 0;
        }
        self::remember($duration);
    }
436163
protected function getEntityManager()
    {
        if (null === $this->entityManager) {
            $reflectionProperty = new \ReflectionProperty(SQLFilter::class, 'em');
            $reflectionProperty->setAccessible(true);
            $this->entityManager = $reflectionProperty->getValue($this);
        }

        return $this->entityManager;
    }
749880
private function entityFactory()
    {
        // this is a little tortuous but some constructor flows require the EntityManager
        // as this point in the refactor I'm unwilling to modify the constructor of the Entity
        // TODO. Fix this. Constructor injection
        $entity = $this->reflEntityClass->newInstanceWithoutConstructor();
        // add the entityManager
        if( $this->reflEntityManagerPropertyOfEntity ) {
            $this->reflEntityManagerPropertyOfEntity->setValue($entity, $this->entityManager);
        }
        // call the original constructor
        call_user_func_array( [$entity, '__construct'], func_get_args() );
        return $entity;
    }
980305
public function getModel()
    {
        $name = $this->getShortName();
        $name = str_replace("Entity", "", $name);

        return CustomPostType::factory($name);
    }
1126935
public function indexAction()
    {
        $businessEntityHelper = $this->get('victoire_core.helper.business_entity_helper');

        //services
        $em = $this->get('doctrine.orm.entity_manager');

        //the repository
        $repository = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate');

        $BusinessTemplates = [];

        $businessEntities = $businessEntityHelper->getBusinessEntities();

        foreach ($businessEntities as $businessEntity) {
            $name = $businessEntity->getName();

            //retrieve the pagePatterns
            $pagePatterns = $repository->findPagePatternByBusinessEntity($businessEntity);

            $BusinessTemplates[$name] = $pagePatterns;
        }

        return new JsonResponse([
                'html' => $this->container->get('templating')->render(
                    'VictoireBusinessPageBundle:BusinessEntity:index.html.twig',
                    [
                        'businessEntities'  => $businessEntities,
                        'BusinessTemplates' => $BusinessTemplates,
                    ]
                ),
                'success' => true,
            ]);
    }
257205
public function getWith()
    {
        // protect entity if it demands that nothing be sideloaded
        if ($this->entityWith == 'block') {
            return 'none';
        }

        // put entity in charge if client defers
        if ($this->suppliedWith == 'default') {
            return $this->entityWith;
        }

        // put client in charge if entity defers
        if ($this->entityWith == 'none') {
            return $this->suppliedWith;
        }

        // check for all
        if ($this->entityWith == 'all' or $this->suppliedWith == 'all') {
            return 'all';
        }

        // return merged result if nothing else was detected
        return $this->entityWith . ',' . $this->suppliedWith;
    }
558469
public function add()
    {
        $uf = new \CUserTypeEntity();
        $result = $uf->Add($this->getFieldsWithDefault());

        if (!$result) {
            global $APPLICATION;
            throw new \Exception($APPLICATION->GetException());
        }

        Logger::log("Добавлен UF {$this->fields['FIELD_NAME']} для {$this->fields['ENTITY_ID']}", Logger::COLOR_GREEN);

        return $result;
    }
274902
public function getLoggerEntityStorage() {
    // TODO: Delete this, after deprecated 'logger_entity' deleting
    // and create instance in __construct.
    if ($this->loggerEntityStorage) {
      return $this->loggerEntityStorage;
    }

    $this->loggerEntityStorage = $this->entityTypeManager
      ->getStorage($this->getLoggerEntityTypeName());
    return $this->loggerEntityStorage;
  }
317951
public function getParentEntityDescriptor()
    {
        if (is_null($this->parentEntityDescriptor)) {
            $this->setParentEntityDescriptor(
                EntityDescriptorRegistry::getInstance()
                    ->getDescriptorFor($this->parentEntity)
            );
        }
        return $this->parentEntityDescriptor;
    }
139182
public function getPackageEntity()
    {
        if ($this->entity === null) {
            $this->entity = $this->app->make(PackageService::class)->getByHandle($this->getPackageHandle());
        }

        return $this->entity;
    }
328030
public function _getEntityManager()
    {
        if ($this->kernel === null) {
            $this->fail('Symfony2 platform module is not loaded');
        }
        if (!isset($this->permanentServices[$this->config['em_service']])) {
            // try to persist configured EM
            $this->persistService($this->config['em_service'], true);

            if ($this->_getContainer()->has('doctrine')) {
                $this->persistService('doctrine', true);
            }
            if ($this->_getContainer()->has('doctrine.orm.default_entity_manager')) {
                $this->persistService('doctrine.orm.default_entity_manager', true);
            }
            if ($this->_getContainer()->has('doctrine.dbal.backend_connection')) {
                $this->persistService('doctrine.dbal.backend_connection', true);
            }
        }
        return $this->permanentServices[$this->config['em_service']];
    }
551052
public function getEntity()
    {
        //if there is no entity
        if ($this->entity === null) {
            //we try to get one from the proxy
            $entityProxy = $this->getEntityProxy();

            //if there is a proxy
            if ($entityProxy !== null && $this->getBusinessEntityId()) {
                $entity = $entityProxy->getEntity($this->getBusinessEntityId());
                $this->entity = $entity;
            }
        }

        return $this->entity;
    }
68952
public static function entityList()
    {
        $files = File::files(config_path('panel'));

        $list = [];
        foreach ($files as $file) {
            $list[] = new self($file);
        }

        return collect($list)->sortBy(function ($entity) {
            return $entity->name();
        });
    }
984804
public function index()
    {
        //Gets all log files, except those serialized
        $logs = collection((new Folder(LOGS))->find('(?!.*_serialized).+\.log'))
            ->map(function ($log) {
                return new Entity([
                    'filename' => $log,
                    'hasSerialized' => is_readable($this->getPath($log, true)),
                    'size' => filesize(LOGS . $log),
                ]);
            });

        $this->set(compact('logs'));
    }
875857
protected function getEncryptedEntity()
    {
        return utf8_encode(Yii::$app->getSecurity()->encryptByKey(Json::encode([
            'entity' => $this->entity,
            'entityId' => $this->entityId,
            'relatedTo' => $this->relatedTo,
        ]), $this->getModule()->id));
    }
186654
private function actionCreate()
    {
        $forms = $this->plugin->getForms();
        $name = arg('name');
        if ($forms->get($name) === false)
        {
            $forms->add($name, arg('code'), arg('title'));
            HTTP::redirect(arg('submitURL'));
        }
        ErrorMessage('Форма с таким именем уже есть! Укажите другое имя.');
        return $this->actionAddDialog();
    }
492525
final protected function _process() {
		/**
		 * 2016-08-22
		 * Помимо добавления поля в таблицу «customer_entity» надо ещё добавить атрибут,
		 * иначе данные не будут сохраняться:
		 *		$attribute = $this->getAttribute($k);
		 *		if (empty($attribute)) {
		 *			continue;
		 *		}
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Eav/Model/Entity/AbstractEntity.php#L1262-L1265
		 */
		if ($this->v('1.7.4')) {
			df_eav_setup()->addAttribute('customer', UpgradeSchema::F__DF, [
				'input' => 'text'
				,'label' => 'Mage2.PRO'
				,'position' => 1000
				,'required' => false
				,'sort_order' => 1000
				,'system' => false
				,'type' => 'static'
				,'visible' => false
			]);
		}
	}