Return the available scenario element from a context
@param array|string $context
@return array|NULL
190711
private function getScenario( $context )
	{
		if ( is_string( $context ) )
		{
			if ( ! isset( $this->contexts[ $context ] ) ) return null;
			$context = $this->contexts[ $context ];
		}

		if ( isset( $context['scenario'] ) ) return $context['scenario'];
		if ( isset( $context['entity']['scenario'] ) ) return $context['entity']['scenario'];

		return null;
	}
845490
protected function resolveContext(array $context = [])
    {
        return array_merge([
            'json_decode_assoc' => $this->assoc,
            'json_decode_depth' => $this->depth,
            'json_decode_options' => $this->optionsMask,
        ], $context);
    }
228891
public static function retrieve($context)
    {
        if ($context instanceof sfContext || $context instanceof sfProjectConfiguration) {
            return $context->getEventDispatcher();
        } elseif (isset($GLOBALS['dispatcher'])) {
            return $GLOBALS['dispatcher'];
        }

        $refClass = new ReflectionClass(get_class($context));

        if ($refClass->hasProperty('dispatcher')) {
            return self::retrieveByDispatcherProperty($refClass, $context);
        } elseif ($refClass->hasProperty('configuration')) {
            return self::retrieveByConfigurationProperty($refClass, $context);
        }
    }
752226
public function getSource(OperationContextInterface $context = null)
    {
        $sourceId = $this->getSourceId();
        if ($sourceId === null) {
            return null;
        }
        $context = $this->ensureContext($context);

        return $this->getSession()->getObject($sourceId, $context);
    }
222204
public function getContext(TemplateContextInterface $context = null)
    {
        $context = new TemplateContext($context);
        $context->setData($this->getData());
        $context->setParameters($this->getParameters());

        return $context;
    }
511719
protected function getExpectedIdentifiers($context = null)
    {
        if ($context === null) {
            throw new Exception\RuntimeException(
                'Expected context to be an array but is null'
            );
        }

        $className = $this->objectRepository->getClassName();

        if ($context instanceof $className) {
            return $this->objectManager
                        ->getClassMetadata($this->objectRepository->getClassName())
                        ->getIdentifierValues($context);
        }

        $result = [];
        foreach ($this->getIdentifiers() as $identifierField) {
            if (! array_key_exists($identifierField, $context)) {
                throw new Exception\RuntimeException(\sprintf('Expected context to contain %s', $identifierField));
            }

            $result[$identifierField] = $context[$identifierField];
        }
        return $result;
    }
493079
protected function get_text_filters($context) {
        if (!isset($this->textfilters[$context->id])) {
            $this->load_filters($context);
        }
        return $this->textfilters[$context->id];
    }
823128
private function configureContext(Context $context)
    {
        foreach ($this->attributes as $key => $value) {
            $context->setAttribute($key, $value);
        }
        if (!empty($this->groups)) {
            $context->setGroups($this->groups);
        }

        if (($context instanceof SerializationContext) && $this->serializeNulls !== null) {
            $context->setSerializeNull($this->serializeNulls);
        }

        if ($this->enableMaxDepthChecks === true) {
            $context->enableMaxDepthChecks();
        }

        if ($this->version !== null) {
            $context->setVersion($this->version);
        }

        return $context;
    }
1042983
public function getContext(ModelContextInterface $context = null)
    {
        $context = new ModelContextDatabase(parent::getContext());
        $context->setQuery($this->getObject('lib:database.query.select'));
        return $context;
    }
1373348
final public function getCanonicalizedLocaleForSelect2(array $context)
    {
        $locale = str_replace('_', '-', $context['app']->getRequest()->getLocale());

        // "en" language doesn't require localization.
        if ('en' === $lang = substr($locale, 0, 2)) {
            return null;
        }

        switch ($locale) {
            case 'pt':
                $locale = 'pt-PT';
                break;
            case 'ug':
                $locale = 'ug-CN';
                break;
            case 'zh':
                $locale = 'zh-CN';
                break;
            default:
                if (!\in_array($locale, ['pt-BR', 'pt-PT', 'ug-CN', 'zh-CN', 'zh-TW'], true)) {
                    $locale = $lang;
                }
        }

        return $locale;
    }
1042560
public function render($context = [])
    {
        parent::render($context);
        $this->getEngine()->parse($this->template);
        $data = [
            'element' => $this->getElement(),
            'context' => $context,
            'renderer' => $this
        ];
        return $this->getEngine()->process($data);
    }
558135
public function render($context)
    {
        $values = array();

        foreach ($this->vars as $var) {
            $actualRow = $this->getRow()->getActualRow();
            $values[] = $actualRow[$var];
        }
        $value = vsprintf($this->value, $values);

        $this->getRow()->addVarAttr($this->name, $value);
        return $context;
    }
339057
public function getActions($context = 'bottom')
    {
        $returnValue = array();

		if(isset($this->actions[$context])){
			$returnValue = $this->actions[$context];
		}

        return (array) $returnValue;
    }
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;

    }
1204734
public function evaluate( Context $context ) {
		/* @var \Ruler\Variable $left */
		list( $left ) = $this->getOperands();

		return null === $left->prepareValue( $context )->getValue();
	}
75654
private function nestContext(&$context)
    {
        foreach ($context as $key => $value) {
            $dot = strpos($key, '.');
            if ($dot && $dot !== strlen($key) - 1) {
                $currentContext = &$context;
                foreach (explode('.', $key) as $k) {
                    if (!isset($currentContext[$k])) {
                        $currentContext[$k] = [];
                    }
                    $currentContext = &$currentContext[$k];
                }
                $currentContext = $value;
                unset($context[$key]);
            }
        }

        return $context;
    }
1027282
public function setContext($context)
    {
        if ($context instanceof Context) {
            $context = [$context];
        }

        if ($context instanceof \ArrayObject || is_array($context) || $context instanceof \Iterator) {
            foreach ($context as $key => $value) {
                if (!$value instanceof Context) {
                    if (is_int($key) && is_array($value) && array_key_exists('key', $value) && array_key_exists('value', $value)) {
                        $contextData = ['key' => $value['key'], 'value' => $value['value']];
                        if (isset($value['id'])) {
                            $contextData['id'] = $value['id'];
                        }
                    } else {
                        $contextData = ['key' => $key, 'value' => $value];
                    }
                    $value = new Context($contextData);
                }

                $value->setNotification($this);
                $this->contexts->add($value);
            }
        }

        return $this;
    }