Elcodi\Plugin\TwitterBundle\Templating\ShareTweetRenderer::renderShareProduct PHP Метод

renderShareProduct() публичный Метод

Renders the share product button.
public renderShareProduct ( Elcodi\Component\Plugin\EventDispatcher\Interfaces\EventInterface $event )
$event Elcodi\Component\Plugin\EventDispatcher\Interfaces\EventInterface 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')]);
        }
    }