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); }
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()]); }
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; }
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')]); }
public function addWidget(WidgetInterface $widget) { $widget->setArea($this); $this->widgets->add($widget); return $this; }
protected function getControllerAttributes(WidgetInterface $widget, $context) { return ['id' => $widget->getId(), '_page_id' => $context['Page']->getId()]; }
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')]); }
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); }
/** * 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); }
public function execute(WidgetInterface $widget) { $posts = $this->postRepository->getRecent($widget->getOption('max')); return $this->render($widget, ['posts' => $posts]); }
public function isVisible(WidgetInterface $widget) { return $widget->getVisibility() === Widget::INCLUDE_ALL; }