local/modules/BetterSeo/Hook/MetaHook.php line 20

  1. <?php
  2. namespace BetterSeo\Hook;
  3. use Symfony\Component\HttpFoundation\RequestStack;
  4. use Thelia\Core\Event\Hook\HookRenderEvent;
  5. use Thelia\Core\Hook\BaseHook;
  6. use Thelia\Core\HttpFoundation\Request;
  7. class MetaHook extends BaseHook
  8. {
  9.     protected $request;
  10.     public function __construct(RequestStack $requestStack)
  11.     {
  12.         $this->request $requestStack->getCurrentRequest();
  13.     }
  14.     public function onMainHeadBottom(HookRenderEvent $event)
  15.     {
  16.         $view $this->request->get('_view');
  17.         if ($view && preg_match('#^[a-zA-Z0-9\-_\.]+$#'$view)) {
  18.             $id $this->request->get($view '_id');
  19.             $lang $this->request->getSession()->getLang();
  20.             $event->add(
  21.                 $this->render('meta_hook.html', [
  22.                     'object_id' => $id,
  23.                     'object_type' => $view,
  24.                     'lang_id' => $lang->getId()
  25.                 ])
  26.             );
  27.         }
  28.     }
  29. }