custom/plugins/econsordev/src/Subscriber/EconsorDevSubscriber.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace EconsorDev\Subscriber;
  3. use Shopware\Storefront\Page\GenericPageLoadedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class EconsorDevSubscriber implements EventSubscriberInterface
  6. {
  7.     public static function getSubscribedEvents(): array
  8.     {
  9.         return [
  10.             GenericPageLoadedEvent::class => 'onPageLoaded',
  11.         ];
  12.     }
  13.     public function onPageLoaded(GenericPageLoadedEvent $event)
  14.     {
  15.         if (!$event->getRequest()->isXmlHttpRequest()) {
  16.             $event->getPage()->getMetaInformation()->setRobots('noindex,nofollow');
  17.         }
  18.     }
  19. }