/** * {@inheritdoc} */ public function normalizeOptions(array &$options, ContextInterface $context, DataAccessorInterface $data) { if (false !== $context->getOr('expressions_evaluate_deferred')) { return; } $evaluate = $context->getOr('expressions_evaluate'); $encoding = $context->getOr('expressions_encoding'); $this->processor->processExpressions($options, $context, $data, $evaluate, $encoding); }
/** * {@inheritdoc} */ public function getPaths(array $existingPaths) { $widgetName = $this->context->getOr('widget_container'); if (!$widgetName) { $widgetName = 'page'; } $paths = []; foreach ($existingPaths as $path) { $paths[] = $path; $paths[] = implode(self::DELIMITER, [$path, $widgetName]); } return $paths; }
/** * {@inheritdoc} */ public function getPaths(array $existingPaths) { $themeName = $this->context->getOr('theme'); if ($themeName) { $themePaths = []; foreach ($this->getThemesHierarchy($themeName) as $theme) { $existingPaths[] = $themePaths[] = $theme->getDirectory(); } $actionName = $this->context->getOr('action'); if ($actionName) { foreach ($themePaths as $path) { $existingPaths[] = implode(self::DELIMITER, [$path, $actionName]); } } $routeName = $this->context->getOr('route_name'); if ($routeName) { foreach ($themePaths as $path) { $existingPaths[] = implode(self::DELIMITER, [$path, $routeName]); } } } return $existingPaths; }
/** * {@inheritdoc} */ protected function loadLayoutUpdates(ContextInterface $context) { $updates = []; if ($context->getOr('theme')) { $iterator = new ResourceIterator($this->findApplicableResources($context)); foreach ($iterator as $file) { $update = $this->loader->load($file); if ($update) { $this->dependencyInitializer->initialize($update); $el = $update instanceof ElementDependentLayoutUpdateInterface ? $update->getElement() : 'root'; $updates[$el][] = $update; } } } return $updates; }
/** * {@inheritdoc} */ public function configureContext(ContextInterface $context) { $context->getResolver()->setOptional(['form'])->setAllowedTypes(['form' => ['null', 'Oro\\Bundle\\LayoutBundle\\Layout\\Form\\FormAccessorInterface']]); $form = $context->getOr('form'); if (null === $form || $form instanceof FormAccessorInterface) { return; } if (is_string($form)) { $form = new DependencyInjectionFormAccessor($this->container, $form, $this->extractFormAction($context), $this->extractFormMethod($context), $this->extractFormEnctype($context)); $context->set('form', $form); } elseif ($form instanceof FormInterface) { $form = new FormAccessor($form, $this->extractFormAction($context), $this->extractFormMethod($context), $this->extractFormEnctype($context)); $context->set('form', $form); } else { throw new \InvalidArgumentException(sprintf('The "form" must be a string, "%s" or "%s", but "%s" given.', 'Symfony\\Component\\Form\\FormInterface', 'Oro\\Bundle\\LayoutBundle\\Layout\\Form\\FormAccessorInterface', $this->getTypeName($form))); } }
/** * Configures the layout context. * * @param ContextInterface $context * @param LayoutAnnotation $layoutAnnotation */ protected function configureContext(ContextInterface $context, LayoutAnnotation $layoutAnnotation) { $action = $layoutAnnotation->getAction(); if (!empty($action)) { $currentAction = $context->getOr('action'); if (empty($currentAction)) { $context->set('action', $action); } } $theme = $layoutAnnotation->getTheme(); if (!empty($theme)) { $currentTheme = $context->getOr('theme'); if (empty($currentTheme)) { $context->set('theme', $theme); } } $vars = $layoutAnnotation->getVars(); if (!empty($vars)) { $context->getResolver()->setRequired($vars); } }