local/modules/HookAnalytics/Hook/FrontHook.php line 26

  1. <?php
  2. /*
  3.  * This file is part of the Thelia package.
  4.  * http://www.thelia.net
  5.  *
  6.  * (c) OpenStudio <info@thelia.net>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace HookAnalytics\Hook;
  12. use HookAnalytics\HookAnalytics;
  13. use Thelia\Core\Event\Hook\HookRenderEvent;
  14. use Thelia\Core\Hook\BaseHook;
  15. /**
  16.  * Class FrontHook.
  17.  *
  18.  * @author Julien Chanséaume <jchanseaume@openstudio.fr>
  19.  */
  20. class FrontHook extends BaseHook
  21. {
  22.     public function onMainHeadBottom(HookRenderEvent $event): void
  23.     {
  24.         $lang $this->getRequest()->getSession()->get('thelia.current.lang');
  25.         if (null !== $lang) {
  26.             $value trim(HookAnalytics::getConfigValue('hookanalytics_trackingcode'''$lang->getLocale()));
  27.             if ('' != $value) {
  28.                 $event->add($value);
  29.             }
  30.         }
  31.     }
  32. }