Vote on a comment.

@param AnCommandContext $context
496023
protected function _actionVoteComment(AnCommandContext $context)
    {
        $this->getCommentController()->id($this->cid)->execute('vote', $context);
    }
967204
public function onCommentChange(AbstractCommentEvent $event)
    {
        $comment = $event->getComment();

        $this
            ->commentCache
            ->invalidateCache(
                $comment->getSource(),
                $comment->getContext()
            );
    }
1088796
protected function _actionUnfollow(AnCommandContext $context)
    {
        $this->getResponse()->status = AnHttpResponse::RESET_CONTENT;
        $this->getItem()->removeFollower($this->actor);

        return $this->getItem();
    }
525442
protected function _afterEntityInsert(AnCommandContext $context)
    {
        parent::_afterEntityInsert($context);

        if ($this->_send_after_insert) {
            //run no more than 30 seconds
            $command = sprintf('php -d max_execution_time=30 %s/index.php %s id=%d >/dev/null 2>&1', ANPATH_BASE, PROCESSOR_PATH, $context->entity->id);
            //error_log($command);
            $result = exec_in_background($command);
        }
    }
1259720
public function createCommentStory(AnCommandContext $context)
    {
        //called by the comment controller as as callback
        $entity = $context->comment;
        $parent = $context->comment->parent;

        $owner = $entity->author;

        if ($parent->isOwnable()) {
            $owner = $parent->owner;
        }

        $data = array(
            'name' => $parent->getIdentifier()->name.'_comment',
            'component' => $parent->component,
            'comment' => $entity,
            'object' => $parent,
            'owner' => $owner,
            'target' => $parent->isOwnable()  ? $parent->owner : null,
        );

        $story = $this->_mixer->createStory($data);

        if ($this->isNotifier()) {
            //story owner
            $data['subscribers'] = array($story->owner);

            //all the not subscribers
            if ($parent->isSubscribable()) {
                $data['subscribers'][] = $parent->subscriberIds->toArray();
            }

            $notification = $this->_mixer->createNotification($data);

            $notification->setType('post');
        }

        $story->save();
    }
582145
protected function _actionPost(AnCommandContext $context)
    {
        $action = $this->getItem() ? 'edit' : 'add';
        $result = $this->execute($action, $context);

        return $result;
    }
1287399
protected function _authorizeMention(AnCommandContext $context)
    {
        if (
            $this->_entity->blocking($this->_viewer) ||
            $this->_viewer->blocking($this->_entity)
            ) {
            return false;
        }

        return true;
    }
644375
protected function _actionBrowse(AnCommandContext $context)
    {
        $context->append(array(
            'query' => $this->getRepository()->getQuery(),
        ));

        $query = $context->query;

        if ($this->q) {
            $query->keyword($this->getService('anahita:filter.term')
                                 ->sanitize($this->q));
        }

        if ($this->ids) {
            $ids = AnConfig::unbox($this->ids);
            $query->id($ids);
        } else {
            $query->limit($this->limit, $this->start);
        }

        $entities = $query->toEntitySet();

        if ($this->isOwnable() && $this->actor) {
            $this->_state->append(array(
                'filter' => 'following',
            ));

            if (
                $this->filter == 'administering' &&
                $this->getRepository()->hasBehavior('administrable')
                ) {
                $entities->where('administrators.id', 'IN', array($this->actor->id));
            } elseif ($this->actor->isFollowable()) {
                $entities->where('followers.id', 'IN', array($this->actor->id));
            }
        }

        $entities->order('created_on', 'desc');

        return $this->setList($entities)->getList();
    }
14987
public function executeRules(Context $context)
    {
        foreach ($this->rules as $rule) {
            $rule->execute($context);
        }
    }
1366206
public function activateFirstAdmin(AnCommandContext $context)
    {
        $person = $context->result;
        $url = route('option=com_people&view=session&isFirstPerson=1&token='.$person->activationCode);
        $context->response->setRedirect($url);
    }
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');
        }
    }
879769
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        if (!get_viewer()->admin()) {
            $query = $context->query;
            $query->where('IF(@col(enabled)=FALSE,0,1)');
        }
    }
1058344
public function redirect(AnCommandContext $context)
    {
        if ($context->action === 'edit' || $context->action === 'add') {
            $context->response->setRedirect(route($this->getItem()->getURL().'&layout=edit'));
        } else {
            return parent::redirect($context);
        }
    }
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();
    }
72644
protected function _actionOptions(AnCommandContext $context)
    {
        $context->response->status = AnHttpResponse::OK;
        $context->response->set('Content-Length', 0);
    }
1135683
public function execute($command, $context)
    {
        if (!$context instanceof  AnCommandContext) {
            $context = new AnCommandContext($context);
        }

        $parts = explode('.', $command);
        $method = '_'.$parts[0].'Entity'.ucfirst($parts[1]);
        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        return $result;
    }
304667
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->parent->getRepository()
                     ->getBehavior('commentable')
                     ->resetStats(array($this->parent));
    }