If a query keyowrd is set it will incorporate it in the search.

@param AnCommandContext $context
162738
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        $query = $context->query;

        if ($query->keyword) {
            $keywords = $query->keyword;

            if ($keywords) {
                if (strpos($keywords, ' OR ')) {
                    $keywords = explode(' OR ', $keywords);
                    $operation = 'OR';
                } else {
                    $keywords = explode(' ', $keywords);
                    $operation = 'AND';
                }

                if (!empty($operation)) {
                    $clause = $query->clause();
                    $search_column = array();

                    foreach ($this->_searchable_properties as $property) {
                        $search_column[] = "IF(@col($property) IS NULL,\"\",@col($property))";
                    }

                    $search_column = implode($search_column, ',');

                    foreach ($keywords as $keyword) {
                        $clause->where('CONCAT('.$search_column.') LIKE @quote(%'.$keyword.'%)', $operation);
                    }
                }
            }
        }
    }
48252
protected function _actionDelete(AnCommandContext $context)
    {
        if ($session = $this->actor->sessions->find(array('api' => $this->getIdentifier()->name))) {
            $session->delete()->save();
        }
    }
155003
protected function _beforeEntityInsert(AnCommandContext $context)
    {
        $max = $this->getScopedQuery($context->entity)->fetchValue('MAX(@col(ordering))');
        $this->ordering = $max + 1;
    }
993480
protected function setContext($context = null)
    {
        if ($context) {
            $this->context = new LogContext($this->parser, $context);
        }
    }
879769
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        if (!get_viewer()->admin()) {
            $query = $context->query;
            $query->where('IF(@col(enabled)=FALSE,0,1)');
        }
    }
798490
protected function _afterSelect(DatabaseContext $context)
    {
        if(!$context->query->isCountQuery())
        {
            $rowset = ObjectConfig::unbox($context->data);

            if ($rowset instanceof DatabaseRowsetInterface)
            {
                //Store the nodes
                $this->__nodes    = $rowset;
                $this->__iterator = null;
                $this->__children = array();

                foreach ($this->__nodes as $key => $row)
                {
                    //Force mixin the behavior into each row
                    $row->mixin($this);

                    if($row->isRecursable()) {
                        $parent = (int) $row->getProperty($this->_parent_column);
                    } else {
                        $parent = 0;
                    }

                    //Store the nodes by parent
                    $this->__children[$parent][$key] = $row;
                }

                //Sort the children
                ksort($this->__children);
            }
        }
    }
1269657
protected function _afterEntityInsert(AnCommandContext $context)
    {
        $this->subscribee->getRepository()
                         ->getBehavior('subscribable')
                         ->resetStats(array($this->subscribee));
    }
330870
protected function _beforeEntityUpdate(AnCommandContext $context)
    {
        if ($this->getModifiedData()->ordering) {
            $store = $this->getRepository()->getStore();
            $query = $this->getScopedQuery($context->entity);
            $change = $this->getModifiedData()->ordering;

            if ($change->new - $change->old < 0) {
                $query->update('@col(ordering) = @col(ordering) + 1');
                $query->where('ordering', '>=',  $change->new)->where('ordering', '<',   $change->old);
            } else {
                $query->update('@col(ordering) = @col(ordering) - 1');
                $query->where('ordering', '>',   $change->old)->where('ordering', '<=',  $change->new);
            }

            $store->execute($query);
        }
    }
675065
public function set_context($context) {
        if ($context === null) {
            // Extremely ugly hack which sets context to some value in order to prevent warnings,
            // use only for core error handling!!!!
            if (!$this->_context) {
                $this->_context = context_system::instance();
            }
            return;
        }
        // Ideally we should set context only once.
        if (isset($this->_context) && $context->id !== $this->_context->id) {
            $current = $this->_context->contextlevel;
            if ($current == CONTEXT_SYSTEM or $current == CONTEXT_COURSE) {
                // Hmm - not ideal, but it might produce too many warnings due to the design of require_login.
            } else if ($current == CONTEXT_MODULE and ($parentcontext = $context->get_parent_context()) and
                $this->_context->id == $parentcontext->id) {
                // Hmm - most probably somebody did require_login() and after that set the block context.
            } else {
                // We do not want devs to do weird switching of context levels on the fly because we might have used
                // the context already such as in text filter in page title.
                debugging("Coding problem: unsupported modification of PAGE->context from {$current} to {$context->contextlevel}");
            }
        }

        $this->_context = $context;
    }
952069
protected function _actionRead(AnCommandContext $context)
    {
        if (! $this->_state->viewer->guest()) {
            $this->_state->setItem($this->_state->viewer);
            $this->getResponse()->setRedirect(route($this->_state->viewer->getURL()));
        }

        return $this->_state->viewer;
    }
998636
protected function _afterEntityInsert(AnCommandContext $context)
    {
        $this->votee->getRepository()
                    ->getBehavior('votable')
                    ->resetStats(array($this->votee));
    }
1056528
protected function _afterRepositoryFetch(AnCommandContext $context)
    {
        if ($this->_enable) {
            $key = $this->_getCacheKey($context->query);
            self::$_cache->offsetSet($key, $context->data);
        }
    }
1038367
protected function _afterEntityInsert(AnCommandContext $context)
    {
        if ($this->isOwnable() && $this->owner->isNotifiable() && !$this->owner->eql($this->author)) {
            $this->addSubscriber($this->owner);
        } elseif (!empty($this->author)) {
            $this->addSubscriber($this->author);
        }
    }
350795
public function setEndDate(AnCommandContext $context)
    {
        $data = $context->data;

        if ($data->day || $data->month || $data->year) {
            $date = new AnDate();
            $date->day((int) $data->day);
            $date->month((int) $data->month);
            $date->year((int) $data->year);
            $data->endDate = $date;
        }
    }
341318
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->votee->getRepository()
                    ->getBehavior('votable')
                    ->resetStats(array($this->votee));
    }
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();
            }
        }
    }
1022378
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        if ($this->_enable) {
            $key = $this->_getCacheKey($context->query);

            if (self::$_cache->offsetExists($key)) {
                $context->data = self::$_cache->offsetGet($key);

                return false;
            }
        }
    }