vendor/symfony/swiftmailer-bundle/DependencyInjection/Compiler/EnsureNoHotPathPass.php line 23

Open in your IDE?
  1. <?php
  2. namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler;
  3. use Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass;
  4. use Symfony\Component\DependencyInjection\Definition;
  5. /**
  6.  * Ensures that autoloading of Swiftmailer classes is not optimized by the hot path optimization.
  7.  *
  8.  * Swiftmailer has a special autoloader triggering the initialization of the library lazily.
  9.  * Bypassing the autoloader would thus break the library.
  10.  * This logic allows to keep applying the autoloading optimization on the container, forcing an
  11.  * opt-out only for the Swiftmailer classes, which is better than disabling the optimization
  12.  * entirely.
  13.  *
  14.  * @author Christophe Coevoet <stof@notk.org>
  15.  */
  16. class EnsureNoHotPathPass extends AbstractRecursivePass
  17. {
  18.     protected function processValue($value$isRoot false)
  19.     {
  20.         if ($value instanceof Definition && === strpos($value->getClass(), 'Swift_')) {
  21.             $value->clearTag('container.hot_path');
  22.         }
  23.         return parent::processValue($value$isRoot);
  24.     }
  25. }