Example #1
0
 public function buildOptionsForm(FormBuilderInterface $builder, array $options, WidgetInterface $originalData)
 {
     $strategy = $this->registry->getStrategy($originalData->getStrategyName());
     // Add custom template override
     $builder->add('template', 'text', ['required' => true, 'help_block' => 'symedit.form.widget.options.template.help', 'constraints' => [new NotBlank()]]);
     $strategy->buildForm($builder);
 }
Example #2
0
 public function execute(WidgetInterface $widget)
 {
     $model = $this->repository->findOneBy(['id' => $widget->getOption('form_builder_id')]);
     if (!$model) {
         return sprintf('Form Builder #%s not found.', $widget->getOption('form_builder_id'));
     }
     $form = $this->factory->build($model);
     return $this->render($widget, ['form' => $form->createView()]);
 }
Example #3
0
 protected function checkAssociation(WidgetInterface $widget, $string)
 {
     $string = rtrim($string, '/');
     foreach ($widget->getAssoc() as $assoc) {
         $assoc = $this->cleanAssociation($assoc);
         if (strpos($assoc, '*') !== false) {
             $exp = sprintf('#%s#i', str_replace('\\*', '.+?', preg_quote($assoc)));
             if (preg_match($exp, $string)) {
                 return true;
             }
         }
         if ($string === $assoc) {
             return true;
         }
     }
     return false;
 }
Example #4
0
 protected function getStrategy(WidgetInterface $widget)
 {
     return $this->registry->getStrategy($widget->getStrategyName());
 }
 public function execute(WidgetInterface $widget)
 {
     $maxEvents = $widget->getOption('max_events');
     $events = $this->repository->getUpcomingEvents($maxEvents);
     $this->render('@SymEdit/Widget/Events/upcoming_events.html.twig', ['events' => $events]);
 }
 /**
  * @return ImageGalleryInterface
  */
 protected function getGallery(WidgetInterface $widget)
 {
     return $this->repository->findOneBy(['slug' => $widget->getOption('slider')]);
 }
Example #7
0
 public function addWidget(WidgetInterface $widget)
 {
     $widget->setArea($this);
     $this->widgets->add($widget);
     return $this;
 }
Example #8
0
 protected function getControllerAttributes(WidgetInterface $widget, $context)
 {
     return ['id' => $widget->getId(), '_page_id' => $context['Page']->getId()];
 }
Example #9
0
 public function execute(WidgetInterface $widget)
 {
     $form = $this->formFactory->create(new SubscribeType(), null, ['action' => $this->router->generate('symedit_mailchimp_subscribe'), 'method' => 'POST', 'list' => $widget->getOption('list')]);
     return $this->render($widget, ['form' => $form->createView(), 'placeholder' => $widget->getOption('placeholder'), 'button_text' => $widget->getOption('button_text')]);
 }
Example #10
0
 public function execute(WidgetInterface $widget, PageInterface $page = null)
 {
     $address = $widget->getOption('address');
     return $this->render($widget, ['query' => empty($address) ? null : $address]);
 }
 /**
  * {@inheritdoc}
  */
 public function render(WidgetInterface $widget, array $parameters = [])
 {
     return $this->templating->render($widget->getOption('template'), $parameters);
 }
Example #12
0
 /**
  * Initiates the Widget with the strategy default options.
  *
  * @param WidgetInterface $widget
  */
 public function init(WidgetInterface $widget, array $options = [])
 {
     $resolver = new OptionsResolver();
     $strategy = $this->getStrategy($widget->getStrategyName());
     $strategy->getDefaultOptions($resolver);
     $resolvedOptions = $resolver->resolve($options);
     // Set options
     $widget->setOptions($resolvedOptions);
 }
Example #13
0
 public function execute(WidgetInterface $widget)
 {
     $posts = $this->postRepository->getRecent($widget->getOption('max'));
     return $this->render($widget, ['posts' => $posts]);
 }
Example #14
0
 public function isVisible(WidgetInterface $widget)
 {
     return $widget->getVisibility() === Widget::INCLUDE_ALL;
 }