method to fetch setting entity

@param AnCommandContext $context Context Parameter

@return ComSettingsDomainEntitySetting object
777446
public function fetchEntity(AnCommandContext $context)
    {
        if (!$this->_entity) {
            if ($entity = $this->getService('com:settings.domain.entity.template')->load($this->alias)) {
                $this->_entity = $entity;
            }
        }

        return $this->_entity;
    }
1337945
final public function fetch()
    {
        if(!isset($this->_entity))
        {
            $context = $this->getContext();
            $context->entity  = null;

            if ($this->invokeCommand('before.fetch', $context) !== false)
            {
                $context->entity = $this->_actionFetch($context);
                $this->invokeCommand('after.fetch', $context);
            }

            $this->_entity = KObjectConfig::unbox($context->entity);
        }

        return $this->_entity;
    }
1363696
protected function _actionGetcandidates(AnCommandContext $context)
    {
        if ($context->request->getFormat() != 'html') {
            $data = $context->data;
            $canditates = $this->getItem()->getAdminCanditates();
            $canditates->keyword($this->value)->limit(10);
            $people = array();

            foreach ($canditates as $person) {
                $people[] = array(
                  'id' => $person->id,
                  'value' => $person->name, );
            }

            $this->getView()->set($people);

            return $people;
        }
    }
689320
protected function _afterEntityInstantiate(AnCommandContext $context)
    {
        $data = $context->data;

        if ($data->portrait) {
            $this->setPortrait($data->portrait);
        }
    }
197977
public function getSync(Context $context = null)
    {
        $activeConfig = $this->config['mysql'][$this->active];
        $client = $this->getDBQueryBuilder($context);
        if ($client->getPdoConnection() === null) {
            return $client->pdoConnect($activeConfig);
        } else {
            return $client;
        }
    }
977144
public function context(Context $context = null) : Context
    {
        if (!$this->context) {
            $this->context = $context ?: new SimpleContext;
        }

        return $this->context;
    }
361846
public function getSettingsByUser($user)
    {
        $userId = $user;
        $userEntity = null;
        if ($user instanceof EntityInterface) {
            $userId = $user->getId();
            $userEntity = $user;
        }
        if (isset($this->settingsByUser[$userId])) {
            return $this->settingsByUser[$user];
        }
        if (empty($userEntity)) {
            $UserRepository = $this->getUserRepository();
            $userEntity = $UserRepository->find($userId);
        }
        
        if (isset($userEntity)) {
            $settingsData = $userEntity->getSettings();
            $this->settingsByUser[$userId] = new SettingsEntity($this);
            $this->settingsByUser[$userId]->setData($settingsData)->spawnAsEntities();
            return $this->settingsByUser[$userId];
        }
        return null;
    }
126736
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        $query = $context->query;
        $services = array_keys(ComConnectHelperApi::getServices());
        $query->api($services);
    }
26606
public function getContext(ViewContextInterface $context = null)
    {
        $context = new ViewContext($context);
        $context->setEntity($this->getModel()->fetch());
        $context->setData($this->getData());
        $context->setParameters($this->getParameters());

        return $context;
    }
326778
public function fetchEntity(AnCommandContext $context)
    {
        if ($this->isDispatched()) {
            $username = $this->getRequest()->username;
            if ($username && $this->getRequest()->get('layout') != 'add') {
                $this->setIdentifiableKey('username');
            }
        }

        return parent::fetchEntity($context);
    }
1056222
private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
    {
        $settings = array();

        foreach (array_keys($this->settingsConfiguration) as $name) {
            try {
                $this->validateSetting($name, $owner);
                $settings[$name] = null;
            } catch (WrongScopeException $e) {
                continue;
            }
        }

        /** @var Setting $setting */
        foreach ($this->repository->findBy(
            array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
        ) as $setting) {
            if (array_key_exists($setting->getName(), $settings)) {
                $settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
            }
        }

        return $settings;
    }
663562
protected function _actionSetPrivacy(AnCommandContext $context)
    {
        if ($this->hasBehavior('privatable')) {
            $this->getBehavior('privatable')->execute('action.setprivacy', $context);
        }

        $data = $context->data;

        if ($data->access != 'followers') {
            $data->allowFollowRequest = false;
        }

        $this->getItem()->allowFollowRequest = (bool) $data->allowFollowRequest;
    }
527468
public function authorizeEcho(AnCommandContext $context)
    {
        $actor = $context->actor;

        if ($actor->isAdministrable() && $actor->authorize('administration')) {
            return true;
        } else {
            return $actor->id == $context->viewer->id;
        }
    }
825391
function getAwaiting(\CharlotteDunois\Livia\Commands\Context $context) {
        if(!\array_key_exists($context->message->author->id.'-'.$context->message->channel->id, $this->awaiting)) {
            throw new \RuntimeException('Context does not exist');
        }
        
        return $this->awaiting[$context->message->author->id.'-'.$context->message->channel->id];
    }
107217
public function fetch(ConnectionContext $context, $source)
    {
        if ($context->mustCache()) {
            $options = $this->connector instanceof ConnectorOptions ? $this->connector->getOptions()->copy() : [];
            ksort($options);

            $this->validateCacheKey($key = $this->cacheKeyGenerator->generateCacheKey($source, $options));

            if ($this->cache->hasItem($key)) {
                return $this->cache->getItem($key)->get();
            }
        }

        $data = $this->connector->fetch($context, $source);

        isset($key) && $this->cache->save($this->cache->getItem($key)->set($data));

        return $data;
    }
773138
protected function _authorizeAction(AnCommandContext $context)
    {
        $method = '_authorize'.ucfirst($context->action);

        $ret = self::AUTH_NOT_IMPLEMENTED;

        if (method_exists($this, $method)) {
            $ret = $this->$method($context->resource);
        } elseif ($context->actor) {
            //check if it's enabled and assigned
            if ($this->_entity->isAssignable()) {
                $ret = $this->_entity->activeForActor($context->actor);
            }
        }

        return $ret;
    }
250053
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        $query = $context->query;
        $repos = $query->getRepository();
        if ($repos->hasBehavior('ownable')) {
            if (!get_viewer()->admin()) {
                $ids = get_viewer()->administratingIds->toArray();
                $ids[] = get_viewer()->id;
                $ids = implode(',', $ids);
                $query->where("IF(@col(enabled) = FALSE, @col(owner.id) IN ($ids) ,1)");
            }
        }
    }