Programming Language PHP

Namespace Oro\Component\Layout\Util

Class BlockUtils

Method/Function setViewVarsFromOptions

Total Examples 13

13 code examples of PHP Oro\Component\Layout\Util\BlockUtils::setViewVarsFromOptions extracted from open source projects

Was this example useful?
0
                                                    public function testSetViewVarsFromOptions()
    {
        $view = new BlockView();
        BlockUtils::setViewVarsFromOptions(
            $view,
            new Options(
                [
                    'test_path' => 'http://example.com',
                    'test_route_name' => 'test_route',
                    'test_route_parameters' => ['foo' => 'bar'],
                ]
            ),
            ['test_route_name', 'test_path']
        );
        $this->assertEquals('http://example.com', $view->vars['test_path']);
        $this->assertEquals('test_route', $view->vars['test_route_name']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions(
            $view,
            $options,
            ['visible', 'translation_domain', 'additional_block_prefixes', 'class_prefix']
        );

        // merge the passed variables with the existing ones
        if (!empty($options['vars'])) {
            foreach ($options['vars'] as $name => $value) {
                $view->vars[$name] = $value;
            }
        }

        // replace attributes if specified ('attr' variable always exists in a view because it is added by FormView)
        if (isset($options['attr'])) {
            $view->vars['attr'] = $options['attr'];
        }

        // add label text and attributes if specified
        if (isset($options['label'])) {
            $view->vars['label'] = $options->get('label', false);
            $view->vars['label_attr'] = [];
            if (isset($options['label_attr'])) {
                $view->vars['label_attr'] = $options->get('label_attr', false);
            }
        }

        // add core variables to the block view, like id, block type and variables required for rendering engine
        $view->vars['id'] = $block->getId();
        $view->vars['block_type'] = $block->getTypeName();
        BlockUtils::populateComputedViewVars($view->vars, $block->getContext()->getHash());
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['name', 'type', 'value', 'placeholder', 'required']);
        if (isset($options['id'])) {
            $view->vars['attr']['id'] = $options->get('id', false);
        }
        if (isset($options['required'])) {
            $view->vars['attr']['required'] = $options->get('required', false);
        }
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        $attributeProxy = $this->createAttributeProxy($options);
        $view->vars['label'] = $this->attributeConfigurationProvider->getAttributeLabel($attributeProxy);

        BlockUtils::setViewVarsFromOptions($view, $options, ['entity', 'value', 'fieldName', 'className']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['group']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['options']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions(
            $view,
            $options,
            ['form_action', 'form_route_name', 'form_route_parameters', 'form_method', 'form_enctype']
        );
        parent::buildView($view, $block, $options);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, LayoutOptions $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['form_data', 'render_rest']);
        parent::buildView($view, $block, $options);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        $formAccessor = $this->getFormAccessor($block->getContext(), $options);
        $view->vars['form'] = $formAccessor->getView($options['field_path']);

        BlockUtils::setViewVarsFromOptions($view, $options, ['field_path']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['render_rest']);
        parent::buildView($view, $block, $options);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['form', 'form_name', 'instance_name']);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, [
            'grid_name',
            'grid_parameters',
            'grid_render_parameters',
        ]);

        $view->vars['split_to_cells'] = $options['split_to_cells'];
        if (!empty($options['grid_scope'])) {
            $view->vars['grid_scope'] = $options->get('grid_scope', false);
            $view->vars['grid_full_name'] = $this->nameStrategy->buildGridFullName(
                $view->vars['grid_name'],
                $view->vars['grid_scope']
            );
        } else {
            $view->vars['grid_full_name'] = $view->vars['grid_name'];
        }
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['enable_tagging']);
    }