/**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $context->getResolver()->setDefaults(['debug' => function (Options $options, $value) {
         if (null === $value) {
             $value = $this->kernel->isDebug();
         }
         return $value;
     }])->setAllowedTypes(['debug' => 'bool']);
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $context->getResolver()->setDefaults(['theme' => function (Options $options, $value) {
         if (null === $value && $this->request) {
             if (null === $value) {
                 $value = $this->request->attributes->get('_theme');
             }
         }
         return $value;
     }])->setAllowedTypes(['theme' => ['string', 'null']]);
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $request = $this->requestStack->getCurrentRequest();
     $context->getResolver()->setDefaults(['widget_container' => function (Options $options, $value) use($request) {
         if (null === $value && $request) {
             $value = $request->query->get('_widgetContainer') ?: $request->request->get('_widgetContainer');
         }
         return $value;
     }])->setAllowedTypes(['widget_container' => ['string', 'null']]);
     $context->data()->setDefault('widget_id', '$request._wid', function () use($request) {
         if (!$request) {
             throw new \BadMethodCallException('The request expected.');
         }
         return $request->query->get('_wid') ?: $request->request->get('_wid');
     });
 }
 /**
  * {@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)));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $context->getResolver()->setDefaults(['expressions_evaluate' => true, 'expressions_evaluate_deferred' => false])->setOptional(['expressions_encoding'])->setAllowedTypes(['expressions_evaluate' => 'bool', 'expressions_evaluate_deferred' => 'bool', 'expressions_encoding' => ['string', 'null']]);
 }
Example #6
0
 /**
  * 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);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $context->getResolver()->setDefaults(['action' => ''])->setAllowedTypes(['action' => 'string']);
 }