Fluxter /
SaasProviderBundle
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /* |
||||||
| 4 | * This file is part of the SaasProviderBundle package. |
||||||
| 5 | * (c) Fluxter <http://fluxter.net/> |
||||||
| 6 | * For the full copyright and license information, please view the LICENSE |
||||||
| 7 | * file that was distributed with this source code. |
||||||
| 8 | */ |
||||||
| 9 | |||||||
| 10 | namespace Fluxter\SaasProviderBundle\EventSubscriber; |
||||||
| 11 | |||||||
| 12 | use Fluxter\SaasProviderBundle\Service\DynamicSaasClientAccessorService; |
||||||
| 13 | use Fluxter\SaasProviderBundle\Service\SaasClientService; |
||||||
| 14 | use Symfony\Component\DependencyInjection\ContainerInterface; |
||||||
| 15 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||||||
| 16 | use Symfony\Component\HttpFoundation\Response; |
||||||
| 17 | use Symfony\Component\HttpKernel\Event\KernelEvent; |
||||||
| 18 | use Symfony\Component\HttpKernel\KernelEvents; |
||||||
| 19 | use Twig\Environment as TwigEnvironment; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 20 | |||||||
| 21 | class ClientSubscriber implements EventSubscriberInterface |
||||||
| 22 | { |
||||||
| 23 | /** @var SaasClientService */ |
||||||
| 24 | private $clientService; |
||||||
| 25 | |||||||
| 26 | /** @var TwigEnvironment */ |
||||||
| 27 | private $twig; |
||||||
| 28 | |||||||
| 29 | /** @var DynamicSaasClientAccessorService */ |
||||||
| 30 | private $dynamicSaasClientAccessorService; |
||||||
| 31 | |||||||
| 32 | /** @var string */ |
||||||
| 33 | private $globalUrl = null; |
||||||
| 34 | |||||||
| 35 | public function __construct( |
||||||
| 36 | SaasClientService $clientService, |
||||||
| 37 | TwigEnvironment $twig, |
||||||
| 38 | DynamicSaasClientAccessorService $dynamicSaasClientAccessorService, |
||||||
| 39 | ContainerInterface $container) |
||||||
| 40 | { |
||||||
| 41 | $this->clientService = $clientService; |
||||||
| 42 | $this->twig = $twig; |
||||||
| 43 | $this->dynamicSaasClientAccessorService = $dynamicSaasClientAccessorService; |
||||||
| 44 | if ($container->hasParameter('saas_provider.global_url')) { |
||||||
| 45 | $this->globalUrl = $container->getParameter('saas_provider.global_url'); |
||||||
| 46 | } |
||||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | public static function getSubscribedEvents() |
||||||
| 50 | { |
||||||
| 51 | $events = [ |
||||||
| 52 | KernelEvents::REQUEST => ['checkSaasClient', 101], |
||||||
| 53 | ]; |
||||||
| 54 | |||||||
| 55 | return $events; |
||||||
| 56 | } |
||||||
| 57 | |||||||
| 58 | /** |
||||||
| 59 | * Discovers and checks if the current saas client exists by the current domain |
||||||
| 60 | * and sets the session variables and updates them if needed. |
||||||
| 61 | * |
||||||
| 62 | * @return void |
||||||
| 63 | */ |
||||||
| 64 | public function checkSaasClient(KernelEvent $event) |
||||||
| 65 | { |
||||||
| 66 | $client = $this->clientService->tryGetCurrentClient(); |
||||||
| 67 | if (null != $this->globalUrl && $this->globalUrl == $this->clientService->getCurrentHttpHost()) { |
||||||
| 68 | // We dont do anything because this is a "not client" page or something ;) |
||||||
| 69 | return; |
||||||
| 70 | } |
||||||
| 71 | |||||||
| 72 | if (null == $client) { |
||||||
| 73 | $event->setResponse(new Response('Not found!', 404)); |
||||||
|
0 ignored issues
–
show
The method
setResponse() does not exist on Symfony\Component\HttpKernel\Event\KernelEvent. It seems like you code against a sub-type of Symfony\Component\HttpKernel\Event\KernelEvent such as Symfony\Component\HttpKernel\Event\ResponseEvent or Symfony\Component\HttpKernel\Event\RequestEvent.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 74 | |||||||
| 75 | return; |
||||||
| 76 | } |
||||||
| 77 | |||||||
| 78 | $this->twig->addGlobal('saas_client_object', $client); |
||||||
| 79 | $this->twig->addGlobal('saas_client', $this->dynamicSaasClientAccessorService); |
||||||
| 80 | } |
||||||
| 81 | } |
||||||
| 82 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths