Create a key by which a binding gets stored.
@param String $subjectModel
@param String $alias
@return String
331199
public static function getStoreKey($subjectModel, $alias) {
        if ($subjectModel == $alias) {
            $subjectModel .= '1';
            $alias .= '2';
        }
        $models = array($subjectModel, $alias);
        sort($models);
        $key = implode('.', $models);
        return $key;
    }
1082361
public function createResultSetMappingBuilder($alias)
    {
        $rsm = new ResultSetMappingBuilder($this->em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
        $rsm->addRootEntityFromClassMetadata($this->entityName, $alias);

        return $rsm;
    }
1258002
protected function _ensureData(Subject $subject)
    {
        $controller = $this->_controller();
        $action = $this->_action();

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        if (isset($controller->viewVars[$viewVar])) {
            return;
        }

        $key = $subject->success ? 'success' : 'error';

        $config = $action->getConfig('api.' . $key);

        $data = [];

        if (isset($config['data']['subject'])) {
            $config['data']['subject'] = Hash::normalize((array)$config['data']['subject']);

            $subjectArray = (array)$subject;
            foreach ($config['data']['subject'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                $keyPath = $this->_expandPath($subject, $keyPath);
                $valuePath = $this->_expandPath($subject, $valuePath);

                $data = Hash::insert($data, $keyPath, Hash::get($subjectArray, $valuePath));
            }
        }

        if (isset($config['data']['entity'])) {
            $config['data']['entity'] = Hash::normalize((array)$config['data']['entity']);

            foreach ($config['data']['entity'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                if (method_exists($subject->entity, $valuePath)) {
                    $data = Hash::insert($data, $keyPath, call_user_func([$subject->entity, $valuePath]));
                } elseif (isset($subject->entity->{$valuePath})) {
                    $data = Hash::insert($data, $keyPath, $subject->entity->{$valuePath});
                }
            }
        }

        if (isset($config['data']['raw'])) {
            foreach ($config['data']['raw'] as $path => $value) {
                $path = $this->_expandPath($subject, $path);
                $data = Hash::insert($data, $path, $value);
            }
        }

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        $controller->set($viewVar, $data);
    }
897695
public static function removeBinding($subjectModel, $alias = false) {
        if ($alias) {
            unset(static::$_bindings[$subjectModel][$alias]);
        } else {
            static::$_bindings[$subjectModel] = array();
        }
        self::resetRecursion($subjectModel);
    }
918905
public function addAlias($alias = null)
    {
        return (new AuthorizationBuilder(TransactionType::ALIAS, $this))
            ->withAlias(AliasAction::ADD, $alias);
    }
599362
public function decorate($subject)
    {
        $items = $this->getItems($subject);

        foreach ($items->keys() as $key) {
            $items->put($key, $this->autoPresenter->decorate($items->get($key)));
        }

        return $subject;
    }
905593
private function evaluateBinding(
        string $alias,
        $target,
        array $parameters,
        string $context = null
    ) {
        if (is_string($target)) {
            //Reference
            return $this->make($target, $parameters, $context);
        }

        if ($target instanceof Autowire) {
            return $target->resolve($this, $parameters);
        }

        if ($target instanceof \Closure) {
            $reflection = new \ReflectionFunction($target);

            //Invoking Closure with resolved arguments
            return $reflection->invokeArgs(
                $this->resolveArguments($reflection, $parameters, $context)
            );
        }

        if (is_array($target) && isset($target[1])) {
            //In a form of resolver and method
            list($resolver, $method) = $target;

            //Resolver instance (i.e. [ClassName::class, 'method'])
            $resolver = $this->get($resolver);
            $method = new \ReflectionMethod($resolver, $method);
            $method->setAccessible(true);

            //Invoking factory method with resolved arguments
            return $method->invokeArgs(
                $resolver,
                $this->resolveArguments($method, $parameters, $context)
            );
        }

        throw new ContainerException("Invalid binding for '{$alias}'");
    }
1123984
public static function create($modelAlias = null, Criteria $criteria = null)
    {
        if ($criteria instanceof ChildSkillReferenceQuery) {
            return $criteria;
        }
        $query = new ChildSkillReferenceQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }
614976
public function addChildObject($alias, $parent_id, $model, $foreignKey) {
        $query = array(
            'alias' => $alias,
            'parent_id' => $parent_id,
            'model' => $model,
            'foreign_key' => $foreignKey
        );

        $result = $this->find('first', array(
            'conditions' => $query
        ));

        if ($result) {
            return $result;
        }

        $this->create();

        if ($this->save($query)) {
            $this->deleteCache(array('RequestObject::hasAlias', $alias));

            return $this->getByAlias($alias);
        }

        return null;
    }
53940
protected function _findRecord($id, Subject $subject)
    {
        $repository = $this->_table();
        $this->_configIndex($repository, $this->_request());

        if ($this->_request()->query('type')) {
            $repository->name($this->_request()->query('type'));
        }

        $query = $repository->find($this->findMethod());
        $query->where(['_id' => $id]);
        $subject->set([
            'repository' => $repository,
            'query' => $query
        ]);
        $this->_trigger('beforeFind', $subject);
        $entity = $query->first();
        if (!$entity) {
            return $this->_notFound($id, $subject);
        }
        $subject->set(['entity' => $entity, 'success' => true]);
        $this->_trigger('afterFind', $subject);

        return $entity;
    }
5705
protected function mapper($alias = false)
    {
        return Manager::getInstance()->getMapper($alias ? $alias : $this->sMapperAlias);
    }
1366895
public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof UserCustomerRelationQuery) {
            return $criteria;
        }
        $query = new UserCustomerRelationQuery(null, null, $modelAlias);

        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }
586910
public function validateEmailSubjectPrefix($subjectPrefix)
    {
        if (mb_strlen($subjectPrefix, 'UTF-8') > 255) {
            $this->addError(EmailConfigurationTransformer::EMAIL_SUBJECT_PREFIX, 'Subject prefix length has to be less or equal to 255');
            return false;
        }

        return true;
    }
444549
public static function getRecursion($subjectModel, $alias) {
        $key = self::getStoreKey($subjectModel, $alias);
        return !array_key_exists($key, static::$_recursion) ? 0 : static::$_recursion[$key];
    }
708847
public function getColExpression($alias, $outputField = null)
    {
        if (is_null($outputField)) {
            $outputField = $this;
        }

        if ($alias !== $this->scopeModel->getMeta()->getDbTable() &&
            $outputField->name !== $this->name) {
            return Col::createObject($alias, $this, $outputField);
        }

        return Col::createObject($alias, $this);
    }
1077456
public static function query($alias = null, $model = null)
    {
        if (!$model) {
            $model = Di::getDefault()->getShared(static::class);
        }

        $query = $model->_di->get('ManaPHP\Db\Query')->setModel($model);
        if ($alias) {
            $query->from(get_class($model), $alias);
        }

        return $query;
    }
409673
public function mapperFor($subject)
    {
        $class = $this->initialize($subject);

        if(!isset($this->_mappers[$class]))
            throw new Exception("No mapper registered for $class");

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