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')]);
}
}