public function onEventTerminate(Application $app)
 {
     // To speed things up (by avoiding Swift Mailer initialization), flush
     // messages only if our mailer has been created (potentially used)
     // IMPORTANT! For files spool you need flush queue from console
     if ($app->getParameter('swiftmailer.initialized') && $app->getParameter('swiftmailer.use_spool') && $app->getParameter('swiftmailer.options.spool_type', 'memory') == 'memory') {
         $app->make('swiftmailer.transport_spool')->getSpool()->flushQueue($app->make('swiftmailer.transport'));
     }
 }
Пример #2
0
 public function register(Application $app)
 {
     $app->singleton('twig', function () use($app) {
         $options = array_replace(['charset' => $app->getParameter('charset'), 'debug' => $app->getParameter('debug'), 'strict_variables' => $app->getParameter('debug')], $app->getParameter('twig.options', []));
         /** @var Twig_LoaderInterface $loader */
         $loader = $app->make('twig.loader');
         $twig = new \Twig_Environment($loader, $options);
         $twig->addGlobal('app', $app);
         return $twig;
     });
     $app->singleton('twig.loader', function () use($app) {
         return new \Twig_Loader_Filesystem($app->getParameter('twig.path'));
     });
 }
Пример #3
0
 public function onEventRequest(Application $app, Request $request)
 {
     /** @var Session $session */
     $session = $app->make('session');
     $request->setSession($session);
 }