Programming Language PHP

Namespace Oro\Component\Layout

Class ContextInterface

Method/Function set

Total Examples 3

3 code examples of PHP Oro\Component\Layout\ContextInterface::set extracted from open source projects

Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function configureContext(ContextInterface $context)
    {
        $context->getResolver()
            ->setRequired(['is_mobile'])
            ->setAllowedTypes('is_mobile', ['boolean']);

        $context->set('is_mobile', $this->userAgentProvider->getUserAgent()->isMobile());
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function configureContext(ContextInterface $context)
    {
        $context->getResolver()
            ->setRequired([self::OPTION_NAME])
            ->setAllowedTypes(self::OPTION_NAME, ['bool']);

        $context->set(self::OPTION_NAME, $this->tokenAccessor->hasUser());
    }
                                            
Was this example useful?
0
                                                    /**
     * Sets grid config for given grid name(-s) into layout context
     *
     * {@inheritdoc}
     */
    public function configureContext(ContextInterface $context)
    {
        if (!$context->has('grid_config')) {
            return;
        }

        $context->getResolver()
            ->setDefined(['grid_config'])
            ->setAllowedTypes('grid_config', ['array']);

        $data = $context->getOr('grid_config');

        if (!is_array($data)) {
            return;
        }

        $gridConfig = [];
        foreach ($data as $gridName) {
            if (!is_string($gridName)) {
                throw new \InvalidArgumentException(
                    sprintf('The "grid_config" value must be a string, but "%s" given.', gettype($gridName))
                );
            }

            $config = $this->dataGridManager->getConfigurationForGrid($gridName);
            $gridConfig[$gridName] = $config->toArray();
        }

        $context->set('grid_config', $gridConfig);
    }
                                            
ContextInterface's Other Methods