Initializes sorting by applying all active sorts through the related column types.

@param ContextInterface $context
341722
protected function initializeSorting(ContextInterface $context)
    {
        if (null !== $activeSort = $context->getActiveSort()) {
            $columnName = $activeSort->getColumnName();
            if ($this->table->hasColumn($columnName)) {
                $this->table->getColumn($columnName)->applySort($this, $activeSort);
            }
        }
    }
404774
public function render(array $data, ContextInterface $context)
    {
        $data = $this->applyButtonClasses($data);

        return parent::render($data, $context);
    }
223707
public function initialize(AgaviContext $context, array $parameters = array())
	{
		parent::initialize($context, $parameters);

		$this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir);
	}
1329085
protected function loadCategories(ContextInterface $context)
    {
        if (\array_key_exists($context->getId(), $this->categories)) {
            return;
        }

        $class = $this->getClass();

        $categories = $this->getObjectManager()->createQuery(sprintf('SELECT c FROM %s c WHERE c.context = :context ORDER BY c.parent ASC', $class))
            ->setParameter('context', $context->getId())
            ->execute();

        if (0 === \count($categories)) {
            // no category, create one for the provided context
            $category = $this->create();
            $category->setName($context->getName());
            $category->setEnabled(true);
            $category->setContext($context);
            $category->setDescription($context->getName());

            $this->save($category);

            $categories = [$category];
        }

        $rootCategories = [];
        foreach ($categories as $pos => $category) {
            if (null === $category->getParent()) {
                $rootCategories[] = $category;
            }

            $this->categories[$context->getId()][$category->getId()] = $category;

            $parent = $category->getParent();

            $category->disableChildrenLazyLoading();

            if ($parent) {
                $parent->addChild($category);
            }
        }

        $this->categories[$context->getId()] = $rootCategories;
    }
610350
public function getRootCategoriesForContext(ContextInterface $context = null)
    {
        $context = $this->getContext($context);

        $this->loadCategories($context);

        return $this->categories[$context->getId()];
    }
660191
protected function createProcessorIterator(ContextInterface $context)
    {
        $action = $context->getAction();
        $actionProcessors = [];
        $processors = $this->configProvider->getProcessors();
        if (!empty($processors[$action])) {
            $actionProcessors = $processors[$action];
        }

        return $this->processorIteratorFactory->createProcessorIterator(
            $actionProcessors,
            $context,
            $this->processorApplicableChecker,
            $this->processorFactory
        );
    }
14987
public function executeRules(Context $context)
    {
        foreach ($this->rules as $rule) {
            $rule->execute($context);
        }
    }
533471
public function appliesToContext(ContextInterface $context): bool
    {
        if (!$context instanceof PropertyContext) {
            return false;
        }

        $property = $context->getProperty();
        if (!preg_match($this->regex, $property->getName())) {
            return false;
        }

        return $this->subRule->appliesToContext($context);
    }
1296868
protected function initContext($context)
    {
        foreach ($context as $key => &$value) {
            switch (gettype($value)) {
                case 'string':
                case 'integer':
                case 'double':
                    // These types require no conversion
                    break;
                case 'array':
                case 'boolean':
                    $value = json_encode($value);
                    break;
                case 'object':
                    if (method_exists($value, '__toString')) {
                        $value = (string)$value;
                    } else {
                        $value = '[object (' . get_class($value) . ')]';
                    }
                    break;
                case 'NULL':
                    $value = 'NULL';
                    break;
                default:
                    $value = '[' . gettype($value) . ']';
                    break;
            }
        }

        return $context;
    }
711471
public function appliesToContext(ContextInterface $context): bool
    {
        if (!$context instanceof TypeContext && !$context instanceof PropertyContext) {
            return false;
        }

        $type = $context->getType();
        if (!preg_match($this->regex, $type->getName())) {
            return false;
        }


        return $this->subRule->appliesToContext($context);
    }
979786
private function skip(ContextInterface $context)
    {
        $dataStack = $context->getDataStack();
        $metadataStack = $context->getMetadataStack();
        $references = [];
        $depth = 0;

        for ($index = count($metadataStack) - 1; $index >= 0; --$index) {
            $metadata = $metadataStack[$index];
            $data = $dataStack[$index];

            if ($metadata instanceof ClassMetadataInterface) {
                $hash = spl_object_hash($data);

                if (!isset($references[$hash])) {
                    $references[$hash] = 0;
                }

                if (++$references[$hash] > $this->circularReferenceLimit) {
                    return true;
                }
            }

            if ($metadata instanceof TypeMetadataInterface) {
                ++$depth;
            }

            if (!$metadata instanceof PropertyMetadataInterface) {
                continue;
            }

            ++$depth;

            if (!$metadata->hasMaxDepth()) {
                continue;
            }

            if ($depth > $metadata->getMaxDepth()) {
                return true;
            }
        }

        return false;
    }
412363
protected function _beforeFetch(KModelContextInterface $context)
    {
        $model = $context->getSubject();

        if ($model instanceof KModelDatabase && !$context->state->isUnique())
        {
            $state = $context->state;

            $sort      = $state->sort;
            $direction = strtoupper($state->direction);
            $columns   = array_keys($this->getTable()->getColumns());

            if ($sort)
            {
                $column = $this->getTable()->mapColumns($sort);

                //if(in_array($column, $columns)) {
                $context->query->order($column, $direction);
                //}
            }

            if ($sort != 'ordering' && in_array('ordering', $columns)) {
                $context->query->order('tbl.ordering', 'ASC');
            }
        }
    }
989071
public function initializeContext(Context $context)
    {
        if (! $context instanceof WordpressAwareInterface) {
            return;
        }

        $context->setWordpress($this->wordpress);
        $context->setWordpressParameters($this->parameters);
    }
662223
public function setContext(array $context)
    {
        $this->clearContext();
        foreach ($context as $key => $value) {
            $this->setContextValue($key, $value);
        }
    }
1139579
public function initializeContext(Context $context) {
        if ($context instanceof ApiClientAwareContext) {
            // Fetch base URI from the Guzzle client configuration, if it exists
            $baseUri = !empty($this->guzzleConfig['base_uri']) ? $this->guzzleConfig['base_uri'] : null;

            if ($baseUri && !$this->validateConnection($baseUri)) {
                throw new RuntimeException(sprintf('Can\'t connect to base_uri: "%s".', $baseUri));
            }

            $context->setClient(new Client($this->guzzleConfig));
        }
    }
1250055
public function addContext(Context $context) {
    $contexts = $this->get('contextOut');
    $contexts[] = $context;
    $this->add('contextOut', $contexts);
  }
276285
private function initLayoutUpdates(ContextInterface $context)
    {
        $loadedLayoutUpdates = $this->loadLayoutUpdates($context);
        foreach ($loadedLayoutUpdates as $id => $layoutUpdates) {
            if (!is_string($id)) {
                throw new Exception\UnexpectedTypeException(
                    $id,
                    'string',
                    'layout item id'
                );
            }
            if (!is_array($layoutUpdates)) {
                throw new Exception\UnexpectedTypeException(
                    $layoutUpdates,
                    'array',
                    sprintf('layout updates for item "%s"', $id)
                );
            }
            foreach ($layoutUpdates as $layoutUpdate) {
                if (!$layoutUpdate instanceof LayoutUpdateInterface) {
                    throw new Exception\UnexpectedTypeException(
                        $layoutUpdate,
                        'Oro\Component\Layout\LayoutUpdateInterface'
                    );
                }
            }
        }
        $this->layoutUpdates = $loadedLayoutUpdates;
    }