Nasty hack to be able to easily display context variables in producers.

@param array $actions
@param $context
349446
protected function debug($actions, &$context)
    {
        if (!is_array($actions)) {
            return;
        }
        foreach ($actions as $action => $parameters) {
            if ('display' == $action) {
                foreach ($parameters as $var) {
                    echo "\n";
                    echo $var.' => ';
                    $command = 'print_r($'.$var.');';
                    eval($command);
                }
                flush();
                ob_flush();
            }

            if ('break' == $action && false !== $parameters) {
                if (function_exists('xdebug_break')) {
                    xdebug_break();
                }
            }

            if ('sleep' == $action) {
                echo 'Sleeping for '.$parameters.' seconds due to sleep step...'."\n";
                sleep($parameters);
            }

            if ('exit' == $action && false !== $parameters) {
                echo 'Exit due to debug step'."\n";
                exit;
            }
        }

        return;
    }
711575
public function addActions(array $actions)
    {
        collect($actions)->each(function ($action) {
            $this->addAction($action);
        });

        return $this;
    }
1047674
protected function _actionBrowse($context)
    {
        $this->getService('repos:photos.set');
        $photos = parent::_actionBrowse($context);
        $photos->order('creationTime', 'DESC');

        if ($this->exclude_set != '') {
            $set = $this->actor->sets->fetch(array('id' => $this->exclude_set));

            if (!empty($set)) {
                $photo_ids = array();

                foreach ($set->photos as $photo) {
                    $photo_ids[] = $photo->id;
                }

                if (count($photo_ids)) {
                    $photos->where('photo.id', '<>', $photo_ids);
                }
            }
        }

        return $photos;
    }
221051
private static function setViewContext($parentActionViewContext, $viewContext) {
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\View', 'viewContext', $viewContext);
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\Html', 'viewContext', $viewContext);
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\Html', 'parentActionViewContext', $parentActionViewContext);
    }
1150309
protected function _actionOptions(DispatcherContext $context)
    {
        $agent   = $context->request->getAgent();
        $pattern = '#(?:Microsoft Office (?:Protocol|Core|Existence)|Microsoft-WebDAV)#i';

        if (preg_match($pattern, $agent)) {
            throw new DispatcherExceptionMethodNotAllowed('Method not allowed');
        }

        $methods = array();

        //Retrieve HTTP methods allowed by the dispatcher
        $actions = array_intersect($this->getActions(), $this->getHttpMethods());

        foreach($actions as $action)
        {
            if($this->canExecute($action)) {
                $methods[] = strtoupper($action);
            }
        }

        $context->response->headers->set('Allow', implode(', ', $methods));
    }
513189
protected function _actionRead(AnCommandContext $context)
    {
        $entity = parent::_actionRead($context);
        $this->getToolbar('menubar')->setTitle(sprintf(AnTranslator::_('COM-HASHTAGS-TERM'), $entity->name));
    }
249596
public function initializeContext(Context $context)
    {
        if (!$context instanceof FixtureServiceAwareContextInterface && !$this->usesReferenceDictionary($context)) {
            return;
        }

        $context->setFixtureService($this->fixtureService);
    }
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);
    }
243390
protected function _actionRead(AnCommandContext $context)
    {
        $apis = ComConnectHelperApi::getServices();

        $this->getService('repos:connect.session');

        $sessions = $this->actor->sessions;

        foreach ($apis as $key => $api) {
            if (!$api->canAddService($this->actor)) {
                unset($apis[$key]);
            }
        }

        $this->apis = $apis;
        $this->sessions = $sessions;
    }
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;
    }
214325
protected function _actionSend(KDispatcherContextInterface $context)
    {
        $request  = $this->getRequest();
        $response = $this->getResponse();

        //Add an Allow header to the response
        if($response->getStatusCode() === KHttpResponse::METHOD_NOT_ALLOWED)
        {
            try {
                $this->_actionOptions($context);
            }
            catch (Exception $e) {}
        }

        parent::_actionSend($context);
    }
1061597
public static function createKey($resource, $context, $action) {
    return $resource.self::$actionDelimiter.$context.self::$actionDelimiter.$action;
  }
229107
private static function cachingClient($actionContext) {
        $cacheSettings = InternalHelper::getStaticPropertyValue('\\PhpMvc\\OutputCache', 'settings');
        $actionName = $actionContext->getActionName();

        // location
        if (!empty($cacheSettings[$actionName]['location'])) {
            $location = intval($cacheSettings[$actionName]['location']);
        }
        elseif (!empty($cacheSettings['.']['location'])) {
            $location = intval($cacheSettings['.']['location']);
        }
        else {
            $location = OutputCacheLocation::ANY;
        }

        // duration
        if (!empty($cacheSettings[$actionName]['duration'])) {
            $duration = intval($cacheSettings[$actionName]['duration']);
        }
        elseif (!empty($cacheSettings['.']['duration'])) {
            $duration = intval($cacheSettings['.']['duration']);
        }
        else {
            $duration = 0;
        }

        // send headers
        $httpContext = $actionContext->getHttpContext();
        $response = $httpContext->getResponse();
        $cacheControl = array();

        switch ($location) {
            case OutputCacheLocation::ANY:
            case OutputCacheLocation::DOWNSTREAM:
                $cacheControl[] = 'public';
                break;

            case OutputCacheLocation::NONE:
                $cacheControl[] = 'no-cache';
                $cacheControl[] = 'must-revalidate';
                $pragma = 'no-cache';
                break;

            case OutputCacheLocation::SERVER:
                $cacheControl[] = 'no-cache';
                $pragma = 'no-cache';
                break;

            case OutputCacheLocation::CLIENT:
            case OutputCacheLocation::SERVER_AND_CLIENT:
                $cacheControl[] = 'private';
                break;
        }

        if ($duration > 0) {
            $cacheControl[] = 'max-age=' . $duration;
        }

        $response->addHeader('Cache-Control', implode(', ', $cacheControl));

        if (isset($pragma)) {
            $response->addHeader('Pragma', $pragma);
        }
    }
515269
public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);

        if ($parts[0] == 'before') {
            $value = pick($this->{$this->getIdentifiableKey()}, $context->data->{$this->getIdentifiableKey()});

            if ($value) {
                $parent = $this->getParentRepository()->fetch($value);

                $this->setParent($parent);

                //set the entity owner as the context actor of the controller
                if ($parent && $this->getRepository()->isOwnable() && $this->isOwnable()) {
                    $this->setActor($parent->owner);
                }

                $context->data['parent'] = $parent;
            }
        }
    }
1363523
public EventBuilder withContexts(Map<String, Map<String, Object>> contexts) {
        event.setContexts(contexts);
        return this;
    }
152822
protected function _actionGetsettings(AnCommandContext $context)
    {
        $entity = $this->getItem();
        $this->getToolbar('actorbar')->setActor($entity);
        $this->getToolbar('actorbar')
             ->setTitle(
                 sprintf(AnTranslator::_('COM-ACTORS-PROFILE-HEADER-EDIT'),
                 $entity->name));
        $dispatcher = $this->getService('anahita:event.dispatcher');
        $entity->components->registerEventDispatcher($dispatcher);
        $dispatcher->addEventListener('onSettingDisplay', $this->_mixer);
    }
1060367
public function execute(Context $context)
    {
        if ($this->evaluate($context) && isset($this->action)) {
            if (!is_callable($this->action)) {
                throw new \LogicException('Rule actions must be callable.');
            }

            call_user_func($this->action);
        }
    }