vendor/rawafed/commons-bundle/Service/ContentApiAccessRestriction.php line 24

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Islam
  5.  * Date: 27/11/2016
  6.  * Time: 11:41 م
  7.  */
  8. namespace Rawafed\CommonsBundle\Service;
  9. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  10. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  11. use Symfony\Component\HttpKernel\KernelInterface;
  12. class ContentApiAccessRestriction
  13. {
  14.     private $kernel;
  15.     public function __construct(KernelInterface $kernel)
  16.     {
  17.         $this->kernel $kernel;
  18.     }
  19.     public function onKernelRequest(GetResponseEvent $event)
  20.     {
  21.         if(!$event->isMasterRequest()) {
  22.             return;
  23.         }
  24.         $request $event->getRequest();
  25.         if(strpos($request->getUri(), '/api/')) {
  26.             if(!in_array('ContentApiBundle'array_keys($this->kernel->getBundles()))) {
  27.                 throw new NotFoundHttpException('Not found');
  28.             }
  29.         }
  30.     }
  31. }