/** * Renders import/export buttons * * @param EventInterface $event * * @return string */ public function renderButtons(EventInterface $event) { if ($event->get('entity_type') !== 'product') { return null; } if ($this->plugin->isUsable()) { $this->appendTemplate('ElcodiProductCsvBundle::buttons.html.twig', $event, $this->plugin); } }
/** * Renders the share product button. * * @param EventInterface $event The event */ public function renderShareProduct(EventInterface $event) { if ($this->plugin->isUsable()) { /** * @var Product $product */ $product = $event->get('product'); $shareUrl = $this->urlGenerator->generate('store_product_view', ['id' => $product->getId(), 'slug' => $product->getSlug()], true); $this->appendTemplate('@ElcodiFacebook/Post/share.html.twig', $event, $this->plugin, ['url' => $shareUrl]); } }
/** * Renders the share product button. * * @param EventInterface $event The event */ public function renderShareProduct(EventInterface $event) { if ($this->plugin->isUsable(['twitter_account'])) { $pluginConfiguration = $this->plugin->getConfiguration(); /** * @var Product $product */ $product = $event->get('product'); $shareUrl = $this->urlGenerator->generate('store_product_view', ['id' => $product->getId(), 'slug' => $product->getSlug()], true); $text = $product->getName(); $category = $product->getPrincipalCategory(); if ($category instanceof CategoryInterface) { $text = $category->getName() . ' - ' . $text; } $this->appendTemplate('@ElcodiTwitter/Tweet/share.html.twig', $event, $this->plugin, ['url' => $shareUrl, 'text' => $text, 'twitter_account' => $pluginConfiguration->getField('twitter_account')]); } }
/** * Render a template and append to the current content. * * @param string $template * @param \Elcodi\Component\Plugin\EventDispatcher\Interfaces\EventInterface $event * @param array $extraContextParams */ protected function appendTemplate($template, \Elcodi\Component\Plugin\EventDispatcher\Interfaces\EventInterface $event, \Elcodi\Component\Plugin\Entity\Plugin $plugin, array $extraContextParams = []) { $event->setContent($event->getContent() . $this->twig->render($template, array_merge($event->getContext(), ['plugin' => $plugin], $extraContextParams))); }