Load context object.

@param Context $context Context object

@return boolean True if the context object was successfully loaded
766448
public function loadContext($context)
    {

        $ok = false;
        if (!empty($context->getRecordId())) {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (context_pk = %d)',
                           $context->getRecordId());
        } else {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (consumer_pk = %d) AND (lti_context_id = %s)',
                           $context->getConsumer()->getRecordId(), DataConnector::quoted($context->ltiContextId));
        }
        $rs_context = mysql_query($sql);
        if ($rs_context) {
            $row = mysql_fetch_object($rs_context);
            if ($row) {
                $context->setRecordId(intval($row->context_pk));
                $context->setConsumerId(intval($row->consumer_pk));
                $context->ltiContextId = $row->lti_context_id;
                $context->type = $row->type;
                $settings = unserialize($row->settings);
                if (!is_array($settings)) {
                    $settings = array();
                }
                $context->setSettings($settings);
                $context->created = strtotime($row->created);
                $context->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
406173
private function expoundContext(&$context)
    {
        foreach ($context as $key => &$value) {
            if (is_array($value) || is_object($value)) {
                $this->expoundContext($value);
            }
            $t    = &$context;
            $keys = explode('.', $key);
            if (count($keys) > 1) {
                foreach ($keys as $subKey) {
                    if (!isset($t[$subKey])) {
                        $t[$subKey] = [];
                    }
                    $t = &$t[$subKey];
                }
                $t = $value;
                unset($context[$key]);
            }
        }
    }
1270502
public function loadFromJson($context=null)
  {
    if($context==null)
      $context = getenv('ERDIKO_CONTEXT');

    return \erdiko\core\Helper::getConfig("authorize",$context);
  }
1335166
public function context(ContextInterface $context)
    {
        if (!empty($this->vary)) {
            $this->varyValue = $context->get($this->vary);
        }
    }
1078319
protected function workOnInstance(Context $context)
    {
        $context = $context->setSerializeNull($this->setSerializeNull);

        // group override?
        if (true === $this->overrideHeaderAllowed &&
            $this->requestStack instanceof RequestStack &&
            $this->requestStack->getCurrentRequest() instanceof Request
        ) {
            $headerValue = $this->requestStack->getCurrentRequest()->headers->get($this->overrideHeaderName);
            if (!is_null($headerValue)) {
                $this->groups = array_map('trim', explode(',', $headerValue));
            }
        }

        $serializerGroups = [GroupsExclusionStrategy::DEFAULT_GROUP];
        if (is_array($this->groups) && !empty($this->groups)) {
            $serializerGroups = array_merge($serializerGroups, $this->groups);
        }

        foreach ($this->exclusionStrategies as $strategy) {
            $context->addExclusionStrategy($strategy);
        }

        return $context->setGroups($serializerGroups);
    }
1125982
protected function load_filters($context) {
        $filters = filter_get_active_in_context($context);
        $this->textfilters[$context->id] = array();
        $this->stringfilters[$context->id] = array();
        foreach ($filters as $filtername => $localconfig) {
            $filter = $this->make_filter_object($filtername, $context, $localconfig);
            if (is_null($filter)) {
                continue;
            }
            $this->textfilters[$context->id][$filtername] = $filter;
            if (in_array($filtername, $this->stringfilternames)) {
                $this->stringfilters[$context->id][$filtername] = $filter;
            }
        }
    }
211474
private function isMute(Context $context) {
	    // <fig:...> tag?
		if($context->view->isFigPrefix($this->name)) {
			return true;
		}

        return ($this->figMute) ? $this->evaluate($context, $this->figMute) : false;
	}
1285029
private static function parseContext($context)
    {
        if(!isset($context['trace']))
        {
            $context['trace'] = static::getTrace();
        }
        if(!isset($context['errorFile']))
        {
            list($file, $line) = static::getErrorFile();
            $context['errorFile'] = $file;
            $context['errorLine'] = $line;
        }
        return $context;
    }
1187162
protected function before(Context $context)
    {
        // kernel before handler
        $context = parent::before($context);

        // add templater to context
        $context->templater = $this->templater;

        // prepare templater helpers and globals vars
        $this->templater->vars['ctx'] = $context;
        $this->templater->helpers['url'] = [$context, 'url'];
        $this->templater->helpers['call'] = [$context, 'forward'];

        return $context;
    }
1311175
protected static function ctxHasCurrentAccount(ContextInterface $context): bool
    {
        /** @var AccountManagerInterface $manager */
        $container = static::ctxGetContainer($context);
        $manager   = $container->get(AccountManagerInterface::class);
        $account   = $manager->getAccount();

        return $account !== null;
    }
639737
protected function _setContext($context)
    {
        $this->context = ($context !== null)
            ? $this->_normalizeContainer($context)
            : null;
    }
116370
protected function render($context)
    {
        $this->runtime->pushContextArray($context);
        $result = $this->runtime->render($this->path . '/renderer');
        $this->runtime->popContext();
        return $result;
    }
1059537
protected function execute(Context $context)
    {
        $this->logger->debug('kernel.execute: execute logic');

        // prepare params
        $params = $context->params;
        $params[] = $context;

        // execute logic method
        $result = call_user_func_array($context->logic->method, $params);
        $this->logger->debug('kernel.execute: #' . $context->logic->name . ' executed');

        // user response
        if($result instanceof Response) {
            $context->response = $result;
            $this->logger->debug('kernel.execute: response provided as result of execution');
        }
        // raw response
        else {
            $context->response->raw = true;
            $context->response->content = $result;
            $this->logger->debug('kernel.execute: raw content provided as result of execution');
        }

        return $context;
    }
1085449
public function appliesToContext(ContextInterface $context): bool
    {
        if (!$context instanceof ClientMethodContext) {
            return false;
        }

        $method = $context->getMethod();
        if (!preg_match($this->regex, $method->getMethodName())) {
            return false;
        }

        return $this->subRule->appliesToContext($context);
    }
272891
private static function check_contexts(context $context, $values) {
        if ($context->contextlevel > CONTEXT_COURSECAT) {
            return self::check_contexts($context->get_parent_context(), $values);
        } else if ($context->contextlevel == CONTEXT_COURSECAT) {
            if (in_array($context->instanceid, $values)) {
                return true;
            } else {
                return self::check_contexts($context->get_parent_context(), $values);
            }
        } else {
            return false;
        }
    }
492008
public function initializeContext(Context $context)
    {
        if (!$context instanceof CollectionAwareContextInterface) {
            return;
        }
        $context->setTerminalCollection($this->collection);
        $context->setTerminalDefaultAlias($this->defaultAlias);
    }