Read Service.

@param AnCommandContext $context
513189
protected function _actionRead(AnCommandContext $context)
    {
        $entity = parent::_actionRead($context);
        $this->getToolbar('menubar')->setTitle(sprintf(AnTranslator::_('COM-HASHTAGS-TERM'), $entity->name));
    }
118405
protected function _actionForward(AnCommandContext $context)
    {
        $response = $this->getController()->getResponse();

        if (! $response->getContent()) {
            if (in_array($response->getStatusCode(), array(201, 205))) {
                $view = $this->getController()->getIdentifier()->name;
                $response->setContent($this->getController()->view($view)->execute('display', $context));

                if ($response->getStatusCode() == 205) {
                    $response->setStatus(200);
                }
            }
        }

        return $context->result;
    }
339842
protected function _afterEntityFetch(AnCommandContext $context)
    {
        //set the persistd flag
        $this->setPersisted(true);

        //set the raw data
        $this->_data->setRowData($context['data']);

        //force setting the keys
        foreach ($context['keys'] as $key => $value) {
            $this->_data[$key] = $value;
        }
    }
200338
protected function _actionRender(AnCommandContext $context)
    {
        if ($context->request->getFormat() == 'html' && AnRequest::type() == 'HTTP') {
            $this->_setPageTitle();
        }

        return parent::_actionRender($context);
    }
1053322
protected function _actionProcess(AnCommandContext $context)
    {
        // run this no more than 1 minute
        //set_time_limit(60);

        $query = $this->getService('repos:notifications.notification')
                      ->getQuery(true)
                      ->status(ComNotificationsDomainEntityNotification::STATUS_NOT_SENT);

        if ($this->id) {
            $ids = (array) AnConfig::unbox($this->id);
            $query->id($ids);
        }

        $notifications = $query->fetchSet();

        $this->sendNotifications($notifications);
    }
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);
    }
879769
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        if (!get_viewer()->admin()) {
            $query = $context->query;
            $query->where('IF(@col(enabled)=FALSE,0,1)');
        }
    }
1274007
protected function _actionRead(ControllerContext $context)
    {
        if(!$context->result instanceof ModelEntityInterface)
        {
            if($this->getModel()->getState()->isUnique())
            {
                $entity = $this->getModel()->fetch();

                if(!count($entity))
                {
                    $name   = ucfirst($this->getView()->getName());
                    throw new ControllerExceptionResourceNotFound($name.' Not Found');
                }
            }
            else $entity = $this->getModel()->create();
        }
        else $entity = $context->result;

        //Set the entity in the context
        $context->setEntity($entity);

        return $entity;
    }
21493
protected function _actionEdit(AnCommandContext $context)
    {
        $context->response->status = AnHttpResponse::RESET_CONTENT;

        return $this->getItem()->setData($context['data']);
    }
840495
public function fetchEntity(AnCommandContext $context)
    {
        if ($this->isDispatched() && $this->getRequest()->alias) {
            $this->setIdentifiableKey('alias');
        }

        return parent::fetchEntity($context);
    }
271481
public function setPageTitle(AnCommandContext $context)
    {
        $controller = $this->getController();

        if (! $controller->isIdentifiable()) {
            return;
        }

        $view = $controller->getView();
        $document = $this->getService('anahita:document');

        //@TODO temporary fix
        if ($document->getTitle()) {
            return;
        }

        $item = $controller->getState()->getItem();
        $actorbar = $controller->actorbar;

        $title = array();
        $description = null;

        if ($actorbar && $actorbar->getActor()) {
            if ($actorbar->getTitle()) {
                $title[] = $actorbar->getTitle();
            }

            $description = $actorbar->getDescription();
        } else {
            $title[] = ucfirst($view->getName());
        }

        if ($item && $item->isDescribable()) {
            array_unshift($title, $item->name);
            $description = $item->body;
        }

        $title = implode(' - ', array_filter(array_unique($title)));

        $document->setTitle($title);
        $document->setDescription($description);

        if ($item) {
            $document->setLink(route($item->getURL()));
            if ($item->isPortraitable()) {
                $document->setImage($item->getPortraitURL('large'));
            } else if ($item->isCoverable()) {
                $document->setImage($item->getCoverURL('large'));
            }

            if ($item instanceof ComActorsDomainEntityActor) {
                $document->setType('profile');
            }

            if ($item instanceof ComMediumDomainEntityMedium) {
                $document->setType('article');
            }
        }
    }
887652
protected function _actionEdit(AnCommandContext $context)
    {
        $data = $context->data;

        //don't overwrite these two
        unset($data->secret);
        unset($data->dbtype);

        $this->_entity->setData(AnConfig::unbox($data));

        if ($this->_entity->save()) {
            $this->setMessage('COM-SETTINGS-PROMPT-SUCCESS', 'success');
        }
    }
845774
protected function _render(AnCommandContext $context)
    {
        dispatch_plugin('system.onBeforeRender', array( $context ));

        $config = array(
            'request' => $context->request,
            'response' => $context->response,
            'theme' => $this->_application->getTemplate(),
        );

        $layout = $this->_request->get('tmpl', 'default');

        $this->getService('com:application.controller.default', $config)
             ->layout($layout)
             ->render();

        dispatch_plugin('system.onAfterRender', array( $context ));
    }
1097919
protected function _actionBrowse(AnCommandContext $context)
    {
        $entities = parent::_actionBrowse($context);

        if ($this->type) {
            $entities->where('folder', '=', $this->type);
        }

        $entities->order($this->sort);

        return $entities;
    }
1056528
protected function _afterRepositoryFetch(AnCommandContext $context)
    {
        if ($this->_enable) {
            $key = $this->_getCacheKey($context->query);
            self::$_cache->offsetSet($key, $context->data);
        }
    }
809137
public function execute($command, AnCommandContext $context)
    {
        $identifier = $context->caller->getIdentifier();
        $type = $identifier->path;
        $type = array_pop($type);
        $parts = explode('.', $command);
        $method = '_'.($parts[0]).ucfirst($type).ucfirst($parts[1]);
        if (method_exists($this, $method)) {
            return $this->$method($context);
        }
    }
623523
protected function _actionGet(AnCommandContext $context)
    {
        if ($context->request->getFormat() == 'html') {
            $context->response->setRedirect(route('format=json&option=com_connect&view='.$this->view));
            return;
        }

        if ($this->get) {
            $url = ltrim($this->get, '/');
            $data = AnConfig::unbox($this->api->get($url));
            $data = json_encode($data);
        } else {
            $data = (array) $this->api->getUser();
        }

        $this->getView()->data($data);

        return parent::_actionGet($context);
    }