vendor/gos/web-socket-bundle/DependencyInjection/CompilerPass/PingableDriverCompilerPass.php line 12

Open in your IDE?
  1. <?php
  2. namespace Gos\Bundle\WebSocketBundle\DependencyInjection\CompilerPass;
  3. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  4. use Symfony\Component\DependencyInjection\ContainerBuilder;
  5. use Symfony\Component\DependencyInjection\Reference;
  6. use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
  7. @trigger_error(
  8.     sprintf('The %s class is deprecated will be removed in 2.0.'PingableDriverCompilerPass::class),
  9.     E_USER_DEPRECATED
  10. );
  11. /**
  12.  * @deprecated to be removed in 2.0.
  13.  */
  14. class PingableDriverCompilerPass implements CompilerPassInterface
  15. {
  16.     /**
  17.      * @param ContainerBuilder $container
  18.      */
  19.     public function process(ContainerBuilder $container)
  20.     {
  21.         if (false === $container->hasParameter('database_driver')) {
  22.             return;
  23.         }
  24.         if (false === $container->hasAlias('gos_web_socket.session_handler')) {
  25.             return;
  26.         }
  27.         $sessionHandlerDefinition $container->getDefinition((string) $container->getAlias('gos_web_socket.session_handler'));
  28.         if (PdoSessionHandler::class !== $sessionHandlerDefinition->getClass() && ( !class_exists($sessionHandlerDefinition->getClass()) || !\in_array(PdoSessionHandler::class, \class_parents($sessionHandlerDefinition->getClass()), true))) {
  29.             return;
  30.         }
  31.         if (!$container->hasDefinition('pdo') || !$container->hasAlias('pdo')) {
  32.             $pdoReference $sessionHandlerDefinition->getArgument(0);
  33.             if (!$pdoReference instanceof Reference || \PDO::class !== $container->getDefinition((string) $pdoReference)->getClass()) {
  34.                 return;
  35.             }
  36.             $periodicPingDefinition $container->getDefinition('gos_web_socket.pdo.periodic_ping');
  37.             $periodicPingDefinition->setArgument(0$pdoReference);
  38.         }
  39.         $periodicRegistryDef $container->getDefinition('gos_web_socket.periodic.registry');
  40.         $pdoDriver = ['pdo_mysql''pdo_sqlite''pdo_pgsql'];
  41.         if (in_array($container->getParameter('database_driver'), $pdoDriver)) {
  42.             $periodicRegistryDef->addMethodCall(
  43.                 'addPeriodic', [new Reference('gos_web_socket.pdo.periodic_ping')]
  44.             );
  45.         }
  46.     }
  47. }