Add a cover.

@param AnCommandContext $context Context parameter

@return AnDomainEntityAbstract
335962
public function addCover(AnCommandContext $context)
    {
        $entity = $this->getItem();
        
        if ($entity->isCoverable() && AnRequest::has('files.cover')) {
            $file = AnRequest::get('files.cover', 'raw');

            if ($this->_mixer->bellowSizeLimit($file) && $file['error'] == 0) {
                $entity->setCover(array('url' => $file['tmp_name'], 'mimetype' => $file['type']));
            }
        }

        return $entity;
    }
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');
        }
    }
72644
protected function _actionOptions(AnCommandContext $context)
    {
        $context->response->status = AnHttpResponse::OK;
        $context->response->set('Content-Length', 0);
    }
700842
protected function _actionEdit(AnCommandContext $context)
    {
        $result = parent::_actionEdit($context);
        $this->registerCallback('after.edit', array($this, 'redirect'));
    }
1064928
protected function _authorizeRemoveAdmin(AnCommandContext $context)
    {
        if ($this->_entity->isAdministrable()) {
            return ($this->_entity->administratorIds->count() >= 2);
        }

        return false;
    }
1324871
public function addContext(array $context)
    {
        if ($context) {
            $this->context = array_merge($this->context, $context);
        }

        return $this;
    }
152106
protected function _beforeControllerAdd(AnCommandContext $context)
    {
        if (!$context->data['owner'] instanceof ComActorsDomainEntityActor) {
            if ($this->getRepository()->hasBehavior('ownable')) {
                $context->data['owner'] = $this->actor;
            }
        }
    }
706571
protected function _beforeEntityUpdate(AnCommandContext $context)
    {
        $modifications = $this->getModifiedData();

        if (isset($this->__restored)) {
            return;
        }

        if (
              $modifications->name ||
              $modifications->body ||
              $modifications->excerpt
        ) {
            $revision = $this->addNewRevision();

            foreach ($modifications as $property => $change) {
                $revision->$property = $change->old;
            }
        }
    }
438297
public function redirect(AnCommandContext $context)
    {
        $url = null;

        if ($context->action == 'delete') {
            $url = 'option=com_'.$this->getIdentifier()->package.'&view='.AnInflector::pluralize($this->getIdentifier()->name);
        } elseif ($context->action == 'add') {
            $url = $context->result->getURL().'&get=settings';
        }

        if ($url) {
            $context->response->setRedirect(route($url));
        }
    }
392216
protected function _beforeEntityInsert(AnCommandContext $context)
    {
        if (!empty($this->couponCode)) {
            $coupon = $this->getService('repos:subscriptions.coupon')
                           ->find(array(
                             'code' => $this->couponCode,
                           ));

            if ($coupon) {
                $coupon->used();
            }
        }
    }
1331439
protected function _actionBrowse(AnCommandContext $context)
    {
        $entities = parent::_actionBrowse($context);

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

        return $entities;
    }
1097919
protected function _actionBrowse(AnCommandContext $context)
    {
        $entities = parent::_actionBrowse($context);

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

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

        return $entities;
    }
747486
public function setContext(Context $context)
    {
        $this->context = $context;

        if (empty($this->parameters['secret'])) {
            $this->parameters['secret'] = $context->getSecret();
        }

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

        return $this->getItem()->setData($context['data']);
    }
847912
protected function _actionPost(AnCommandContext $context)
    {
        $context->append(array(
            'data' => AnRequest::get('post', 'raw', array()),
        ));

        //backward compatiblity
        if ($context->data['action']) {
            $context->data['_action'] = $context->data['action'];
        }

        $action = 'post';

        if ($context->data['_action']) {
            $action = $context->data['_action'];
            if (in_array($action, array('browse', 'read', 'display'))) {
                throw new LibBaseControllerExceptionMethodNotAllowed('Action: '.$action.' not allowed');
            }
        }

        if ($context->request->getFormat() == 'json' || $context->request->isAjax()) {
            $this->registerCallback('after.post', array($this, 'forward'));
        } else {
            $context->response->setRedirect(AnRequest::get('server.HTTP_REFERER', 'url'));
        }

        return $this->getController()->execute($action, $context);
    }
512103
protected function _afterEntityInsert(AnCommandContext $context)
    {
        $actorIds = $this->package->getActorIds();

        if (count($actorIds)) {
            $actors = $this->getService('repos:actors.actor')
                           ->getQuery(true)
                           ->where('id', 'IN', $actorIds)
                           ->fetchSet();

            foreach ($actors as $actor) {
                $actor->addFollower($this->person);
            }
        }
    }
641728
protected function _actionDelete(AnCommandContext $context)
    {
        $this->getResponse()->status = AnHttpResponse::NO_CONTENT;

        $token = $this->getService('repos:connect.session')->fetchSet(array(
                        'owner' => $this->actor,
                        'api' => $this->getAPI()->getName(),
                    ));

        $token->delete()->save();
    }