Beispiel #1
0
 public function register(Application $app)
 {
     $app['swiftmailer.options'] = array_replace(array('host' => 'localhost', 'port' => 25, 'username' => '', 'password' => '', 'encryption' => null, 'auth_mode' => null), isset($app['swiftmailer.options']) ? $app['swiftmailer.options'] : array());
     $app['mailer'] = $app->share(function () use($app) {
         $r = new \ReflectionClass('Swift_Mailer');
         require_once dirname($r->getFilename()) . '/../../swift_init.php';
         return new \Swift_Mailer($app['swiftmailer.transport']);
     });
     $app['swiftmailer.transport'] = $app->share(function () use($app) {
         $transport = new \Swift_Transport_EsmtpTransport($app['swiftmailer.transport.buffer'], array($app['swiftmailer.transport.authhandler']), $app['swiftmailer.transport.eventdispatcher']);
         $transport->setHost($app['swiftmailer.options']['host']);
         $transport->setPort($app['swiftmailer.options']['port']);
         $transport->setEncryption($app['swiftmailer.options']['encryption']);
         $transport->setUsername($app['swiftmailer.options']['username']);
         $transport->setPassword($app['swiftmailer.options']['password']);
         $transport->setAuthMode($app['swiftmailer.options']['auth_mode']);
         return $transport;
     });
     $app['swiftmailer.transport.buffer'] = $app->share(function () {
         return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     });
     $app['swiftmailer.transport.authhandler'] = $app->share(function () {
         return new \Swift_Transport_Esmtp_AuthHandler(array(new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()));
     });
     $app['swiftmailer.transport.eventdispatcher'] = $app->share(function () {
         return new \Swift_Events_SimpleEventDispatcher();
     });
     if (isset($app['swiftmailer.class_path'])) {
         $app['autoloader']->registerPrefix('Swift_', $app['swiftmailer.class_path']);
     }
 }
 public function register(Application $app)
 {
     $app['swiftmailer.options'] = array();
     $app['mailer.initialized'] = false;
     $app['mailer'] = $app->share(function ($app) {
         $app['mailer.initialized'] = true;
         return new \Swift_Mailer($app['swiftmailer.spooltransport']);
     });
     $app['swiftmailer.spooltransport'] = $app->share(function ($app) {
         return new \Swift_SpoolTransport($app['swiftmailer.spool']);
     });
     $app['swiftmailer.spool'] = $app->share(function ($app) {
         return new \Swift_MemorySpool();
     });
     $app['swiftmailer.transport'] = $app->share(function ($app) {
         $transport = new \Swift_Transport_EsmtpTransport($app['swiftmailer.transport.buffer'], array($app['swiftmailer.transport.authhandler']), $app['swiftmailer.transport.eventdispatcher']);
         $options = $app['swiftmailer.options'] = array_replace(array('host' => 'localhost', 'port' => 25, 'username' => '', 'password' => '', 'encryption' => null, 'auth_mode' => null), $app['swiftmailer.options']);
         $transport->setHost($options['host']);
         $transport->setPort($options['port']);
         $transport->setEncryption($options['encryption']);
         $transport->setUsername($options['username']);
         $transport->setPassword($options['password']);
         $transport->setAuthMode($options['auth_mode']);
         return $transport;
     });
     $app['swiftmailer.transport.buffer'] = $app->share(function () {
         return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     });
     $app['swiftmailer.transport.authhandler'] = $app->share(function () {
         return new \Swift_Transport_Esmtp_AuthHandler(array(new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()));
     });
     $app['swiftmailer.transport.eventdispatcher'] = $app->share(function () {
         return new \Swift_Events_SimpleEventDispatcher();
     });
 }
 protected function createSmtp(array $config)
 {
     $buffer = new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     $auth = new \Swift_Transport_Esmtp_AuthHandler([new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()]);
     $transport = new \Swift_Transport_EsmtpTransport($buffer, [$auth], $this->dispatcher);
     $transport->setHost($config['host']);
     $transport->setPort($config['port']);
     $transport->setUsername($config['username']);
     $transport->setPassword($config['password']);
     $transport->setEncryption($config['encryption']);
     $transport->setAuthMode($config['auth_mode']);
     return $transport;
 }
 public function register(Container $app)
 {
     $app['swiftmailer.options'] = array();
     $app['swiftmailer.use_spool'] = true;
     $app['mailer.initialized'] = false;
     $app['mailer'] = function ($app) {
         $app['mailer.initialized'] = true;
         $transport = $app['swiftmailer.use_spool'] ? $app['swiftmailer.spooltransport'] : $app['swiftmailer.transport'];
         return new \Swift_Mailer($transport);
     };
     $app['swiftmailer.spooltransport'] = function ($app) {
         return new \Swift_Transport_SpoolTransport($app['swiftmailer.transport.eventdispatcher'], $app['swiftmailer.spool']);
     };
     $app['swiftmailer.spool'] = function ($app) {
         return new \Swift_MemorySpool();
     };
     $app['swiftmailer.transport'] = function ($app) {
         $transport = new \Swift_Transport_EsmtpTransport($app['swiftmailer.transport.buffer'], array($app['swiftmailer.transport.authhandler']), $app['swiftmailer.transport.eventdispatcher']);
         $options = $app['swiftmailer.options'] = array_replace(array('host' => 'localhost', 'port' => 25, 'username' => '', 'password' => '', 'encryption' => null, 'auth_mode' => null), $app['swiftmailer.options']);
         $transport->setHost($options['host']);
         $transport->setPort($options['port']);
         $transport->setEncryption($options['encryption']);
         $transport->setUsername($options['username']);
         $transport->setPassword($options['password']);
         $transport->setAuthMode($options['auth_mode']);
         if (null !== $app['swiftmailer.sender_address']) {
             $transport->registerPlugin(new \Swift_Plugins_ImpersonatePlugin($app['swiftmailer.sender_address']));
         }
         if (!empty($app['swiftmailer.delivery_addresses'])) {
             $transport->registerPlugin(new \Swift_Plugins_RedirectingPlugin($app['swiftmailer.delivery_addresses'], $app['swiftmailer.delivery_whitelist']));
         }
         return $transport;
     };
     $app['swiftmailer.transport.buffer'] = function () {
         return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     };
     $app['swiftmailer.transport.authhandler'] = function () {
         return new \Swift_Transport_Esmtp_AuthHandler(array(new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()));
     };
     $app['swiftmailer.transport.eventdispatcher'] = function () {
         return new \Swift_Events_SimpleEventDispatcher();
     };
     $app['swiftmailer.sender_address'] = null;
     $app['swiftmailer.delivery_addresses'] = [];
     $app['swiftmailer.delivery_whitelist'] = [];
 }
 public function register(Container $c)
 {
     $c['swiftmailer.use_spool'] = true;
     $c['mailer.initialized'] = false;
     $c['mailer'] = function ($c) {
         $c['mailer.initialized'] = true;
         $transport = $c['swiftmailer.use_spool'] ? $c['swiftmailer.spooltransport'] : $c['swiftmailer.transport'];
         return new \Swift_Mailer($transport);
     };
     $c['swiftmailer.spooltransport'] = function ($c) {
         return new \Swift_Transport_SpoolTransport($c['swiftmailer.transport.eventdispatcher'], $c['swiftmailer.spool']);
     };
     $c['swiftmailer.spool'] = function ($c) {
         return new \Swift_MemorySpool();
     };
     $c['swiftmailer.transport'] = function ($c) {
         $settings = $c["settings"]["swiftmailer"];
         $transport = new \Swift_Transport_EsmtpTransport($c['swiftmailer.transport.buffer'], array($c['swiftmailer.transport.authhandler']), $c['swiftmailer.transport.eventdispatcher']);
         $settings = array_replace(array('host' => 'localhost', 'port' => 25, 'username' => '', 'password' => '', 'encryption' => null, 'auth_mode' => null), $settings);
         $transport->setHost($settings['host']);
         $transport->setPort($settings['port']);
         $transport->setEncryption($settings['encryption']);
         $transport->setUsername($settings['username']);
         $transport->setPassword($settings['password']);
         $transport->setAuthMode($settings['auth_mode']);
         return $transport;
     };
     $c['swiftmailer.transport.buffer'] = function ($c) {
         return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     };
     $c['swiftmailer.transport.authhandler'] = function ($c) {
         return new \Swift_Transport_Esmtp_AuthHandler(array(new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()));
     };
     $c['swiftmailer.transport.eventdispatcher'] = function ($c) {
         return new \Swift_Events_SimpleEventDispatcher();
     };
 }
 /**
  * Gets the 'swiftmailer.transport' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return Swift_Transport_EsmtpTransport A Swift_Transport_EsmtpTransport instance.
  */
 protected function getSwiftmailer_TransportService()
 {
     $this->services['swiftmailer.transport'] = $instance = new \Swift_Transport_EsmtpTransport(new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()), array(0 => new \Swift_Transport_Esmtp_AuthHandler(array(0 => new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), 1 => new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), 2 => new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()))), new \Swift_Events_SimpleEventDispatcher());
     $instance->setHost('localhost');
     $instance->setPort(25);
     $instance->setEncryption(NULL);
     $instance->setUsername('');
     $instance->setPassword('');
     $instance->setAuthMode(NULL);
     $instance->registerPlugin($this->get('swiftmailer.plugin.messagelogger'));
     return $instance;
 }
 protected function getSwiftmailer_Mailer_Default_Transport_RealService()
 {
     $this->services['swiftmailer.mailer.default.transport.real'] = $instance = new \Swift_Transport_EsmtpTransport(new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()), array(0 => new \Swift_Transport_Esmtp_AuthHandler(array(0 => new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), 1 => new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), 2 => new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()))), $this->get('swiftmailer.mailer.default.transport.eventdispatcher'));
     $instance->setHost('127.0.0.1');
     $instance->setPort(25);
     $instance->setEncryption(NULL);
     $instance->setUsername(NULL);
     $instance->setPassword(NULL);
     $instance->setAuthMode(NULL);
     $instance->setTimeout(30);
     $instance->setSourceIp(NULL);
     return $instance;
 }
Beispiel #8
0
use Pagekit\Mail\Mailer;
use Pagekit\Mail\Plugin\ImpersonatePlugin;
return ['name' => 'system/mail', 'main' => function ($app) {
    $app['mailer'] = function ($app) {
        $app['mailer.initialized'] = true;
        $mailer = new Mailer($app['swift.transport'], $app['swift.spooltransport']);
        $mailer->registerPlugin(new ImpersonatePlugin($this->config['from_address'], $this->config['from_name']));
        return $mailer;
    };
    $app['mailer.initialized'] = false;
    $app['swift.transport'] = function ($app) {
        if ('smtp' == $this->config['driver']) {
            $transport = new Swift_Transport_EsmtpTransport($app['swift.transport.buffer'], [$app['swift.transport.authhandler']], $app['swift.transport.eventdispatcher']);
            $transport->setHost($this->config['host']);
            $transport->setPort($this->config['port']);
            $transport->setUsername($this->config['username']);
            $transport->setPassword($this->config['password']);
            $transport->setEncryption($this->config['encryption']);
            $transport->setAuthMode($this->config['auth_mode']);
            return $transport;
        }
        if ('mail' == $this->config['driver']) {
            return Swift_MailTransport::newInstance();
        }
        throw new \InvalidArgumentException('Invalid mail driver.');
    };
    $app['swift.transport.buffer'] = function () {
        return new Swift_Transport_StreamBuffer(new Swift_StreamFilters_StringReplacementFilterFactory());
    };
    $app['swift.transport.authhandler'] = function () {
        return new Swift_Transport_Esmtp_AuthHandler([new Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new Swift_Transport_Esmtp_Auth_PlainAuthenticator()]);
Beispiel #9
0
 private function setupSwiftMailer()
 {
     $this['swiftmailer.transport'] = $this->share(function (Application $app) {
         if ($app['conf']->get(['registry', 'email', 'smtp-enabled'])) {
             $transport = new \Swift_Transport_EsmtpTransport($app['swiftmailer.transport.buffer'], [$app['swiftmailer.transport.authhandler']], $app['swiftmailer.transport.eventdispatcher']);
             $encryption = null;
             if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tls'])) {
                 $encryption = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);
             }
             $options = $app['swiftmailer.options'] = array_replace(['host' => $app['conf']->get(['registry', 'email', 'smtp-host']), 'port' => $app['conf']->get(['registry', 'email', 'smtp-port']), 'username' => $app['conf']->get(['registry', 'email', 'smtp-user']), 'password' => $app['conf']->get(['registry', 'email', 'smtp-password']), 'encryption' => $encryption, 'auth_mode' => null], $app['swiftmailer.options']);
             $transport->setHost($options['host']);
             $transport->setPort($options['port']);
             // tls or ssl
             $transport->setEncryption($options['encryption']);
             if ($app['conf']->get(['registry', 'email', 'smtp-auth-enabled'])) {
                 $transport->setUsername($options['username']);
                 $transport->setPassword($options['password']);
                 $transport->setAuthMode($options['auth_mode']);
             }
         } else {
             $transport = new \Swift_Transport_MailTransport(new \Swift_Transport_SimpleMailInvoker(), $app['swiftmailer.transport.eventdispatcher']);
         }
         return $transport;
     });
 }
 protected function getSwiftmailer_TransportService()
 {
     $this->services['swiftmailer.transport'] = $instance = new \Swift_Transport_EsmtpTransport(new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()), array(0 => new \Swift_Transport_Esmtp_AuthHandler(array(0 => new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), 1 => new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), 2 => new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()))), new \Swift_Events_SimpleEventDispatcher());
     $instance->setHost('smtp.gmail.com');
     $instance->setPort(465);
     $instance->setEncryption('ssl');
     $instance->setUsername('richpolis');
     $instance->setPassword('D3m3s1s1');
     $instance->setAuthMode('login');
     return $instance;
 }
 public function __construct($environment = self::ENV_PROD)
 {
     parent::__construct();
     error_reporting(-1);
     $this['root.path'] = realpath(__DIR__ . '/../../..');
     $this->environment = $environment;
     mb_internal_encoding("UTF-8");
     !defined('JETON_MAKE_SUBDEF') ? define('JETON_MAKE_SUBDEF', 0x1) : '';
     !defined('JETON_WRITE_META_DOC') ? define('JETON_WRITE_META_DOC', 0x2) : '';
     !defined('JETON_WRITE_META_SUBDEF') ? define('JETON_WRITE_META_SUBDEF', 0x4) : '';
     !defined('JETON_WRITE_META') ? define('JETON_WRITE_META', 0x6) : '';
     $this['charset'] = 'UTF-8';
     $this['debug'] = $this->share(function (Application $app) {
         return Application::ENV_PROD !== $app->getEnvironment();
     });
     if ($this['debug'] === true) {
         ini_set('log_errors', 'on');
         ini_set('error_log', $this['root.path'] . '/logs/php_error.log');
     }
     $this->register(new BasketMiddlewareProvider());
     $this->register(new ACLServiceProvider());
     $this->register(new AuthenticationManagerServiceProvider());
     $this->register(new BorderManagerServiceProvider());
     $this->register(new BrowserServiceProvider());
     $this->register(new ConfigurationServiceProvider());
     $this->register(new ConfigurationTesterServiceProvider());
     $this->register(new ConvertersServiceProvider());
     $this->register(new RegistrationServiceProvider());
     $this->register(new CacheServiceProvider());
     $this->register(new CacheConnectionServiceProvider());
     $this->register(new ImagineServiceProvider());
     $this->register(new JMSSerializerServiceProvider());
     $this->register(new FFMpegServiceProvider());
     $this->register(new FeedServiceProvider());
     $this->register(new FilesystemServiceProvider());
     $this->register(new FtpServiceProvider());
     $this->register(new GeonamesServiceProvider());
     $this['geonames.server-uri'] = $this->share(function (Application $app) {
         return $app['conf']->get(['registry', 'webservices', 'geonames-server'], 'http://geonames.alchemyasp.com/');
     });
     $this->register(new MediaAlchemystServiceProvider());
     $this['media-alchemyst.configuration'] = $this->share(function (Application $app) {
         $configuration = [];
         foreach (['swftools.pdf2swf.binaries' => 'pdf2swf_binary', 'swftools.swfrender.binaries' => 'swf_render_binary', 'swftools.swfextract.binaries' => 'swf_extract_binary', 'unoconv.binaries' => 'unoconv_binary', 'mp4box.binaries' => 'mp4box_binary', 'gs.binaries' => 'ghostscript_binary', 'ffmpeg.ffmpeg.binaries' => 'ffmpeg_binary', 'ffmpeg.ffprobe.binaries' => 'ffprobe_binary', 'ffmpeg.ffmpeg.timeout' => 'ffmpeg_timeout', 'ffmpeg.ffprobe.timeout' => 'ffprobe_timeout', 'gs.timeout' => 'gs_timeout', 'mp4box.timeout' => 'mp4box_timeout', 'swftools.timeout' => 'swftools_timeout', 'unoconv.timeout' => 'unoconv_timeout'] as $parameter => $key) {
             if ($this['conf']->has(['main', 'binaries', $key])) {
                 $configuration[$parameter] = $this['conf']->get(['main', 'binaries', $key]);
             }
         }
         $imagineDriver = $app['conf']->get(['registry', 'executables', 'imagine-driver']);
         $configuration['ffmpeg.threads'] = $app['conf']->get(['registry', 'executables', 'ffmpeg-threads']);
         $configuration['imagine.driver'] = $imagineDriver ?: null;
         return $configuration;
     });
     $this['media-alchemyst.logger'] = $this->share(function (Application $app) {
         return $app['monolog'];
     });
     $this->register(new MediaVorusServiceProvider());
     $this->register(new MonologServiceProvider());
     $this['monolog.name'] = 'Phraseanet logger';
     $this['monolog.handler'] = $this->share(function () {
         return new NullHandler();
     });
     $this['monolog'] = $this->share($this->extend('monolog', function (Logger $monolog) {
         $monolog->pushProcessor(new IntrospectionProcessor());
         return $monolog;
     }));
     $this->register(new MP4BoxServiceProvider());
     $this->register(new NotificationDelivererServiceProvider());
     $this->register(new ORMServiceProvider());
     $this->register(new ManipulatorServiceProvider());
     $this->register(new InstallerServiceProvider());
     $this->register(new PhraseanetServiceProvider());
     $this->register(new PhraseaVersionServiceProvider());
     $this->register(new PHPExiftoolServiceProvider());
     $this->register(new ReCaptchaServiceProvider());
     $this->register(new SubdefServiceProvider());
     $this->register(new ZippyServiceProvider());
     $this['recaptcha.public-key'] = $this->share(function (Application $app) {
         if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
             return $app['conf']->get(['registry', 'webservices', 'recaptcha-public-key']);
         }
     });
     $this['recaptcha.private-key'] = $this->share(function (Application $app) {
         if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
             return $app['conf']->get(['registry', 'webservices', 'recaptcha-private-key']);
         }
     });
     $this->register(new SearchEngineServiceProvider());
     $this->register(new SessionHandlerServiceProvider());
     $this->register(new SessionServiceProvider(), ['session.test' => $this->getEnvironment() === static::ENV_TEST]);
     $this['session.storage.test'] = $this->share(function ($app) {
         return new MockArraySessionStorage();
     });
     $this['session.storage.handler'] = $this->share(function ($app) {
         return $this['session.storage.handler.factory']->create($app['conf']);
     });
     $this->register(new SerializerServiceProvider());
     $this->register(new ServiceControllerServiceProvider());
     $this->register(new SwiftmailerServiceProvider());
     $this->register(new TasksServiceProvider());
     $this->register(new TemporaryFilesystemServiceProvider());
     $this->register(new TokensServiceProvider());
     $this->register(new TwigServiceProvider(), ['twig.options' => ['cache' => $this['root.path'] . '/tmp/cache_twig/']]);
     $this->register(new TranslationServiceProvider(), ['locale_fallbacks' => ['fr'], 'translator.cache-options' => ['debug' => $this['debug'], 'cache_dir' => $this['root.path'] . '/tmp/translations']]);
     $this['translator'] = $this->share($this->extend('translator', function (CachedTranslator $translator, $app) {
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/messages.fr.xlf', 'fr', 'messages');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/validators.fr.xlf', 'fr', 'validators');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/messages.en.xlf', 'en', 'messages');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/validators.en.xlf', 'en', 'validators');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/messages.de.xlf', 'de', 'messages');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/validators.de.xlf', 'de', 'validators');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/messages.nl.xlf', 'nl', 'messages');
         $translator->addResource('xlf', __DIR__ . '/../../../resources/locales/validators.nl.xlf', 'nl', 'validators');
         return $translator;
     }));
     $this->register(new FormServiceProvider());
     $this['form.type.extensions'] = $this->share($this->extend('form.type.extensions', function ($extensions) {
         $extensions[] = new HelpTypeExtension();
         return $extensions;
     }));
     $this->setupTwig();
     $this->register(new UnoconvServiceProvider());
     $this->register(new UrlGeneratorServiceProvider());
     $this->setupUrlGenerator();
     $this->register(new UnicodeServiceProvider());
     $this->register(new ValidatorServiceProvider());
     $this->register(new XPDFServiceProvider());
     $this->register(new FileServeServiceProvider());
     $this->register(new ManipulatorServiceProvider());
     $this->register(new PluginServiceProvider());
     $this['phraseanet.exception_handler'] = $this->share(function ($app) {
         $handler = PhraseaExceptionHandler::register($app['debug']);
         $handler->setTranslator($app['translator']);
         return $handler;
     });
     $this['swiftmailer.transport'] = $this->share(function ($app) {
         if ($app['conf']->get(['registry', 'email', 'smtp-enabled'])) {
             $transport = new \Swift_Transport_EsmtpTransport($app['swiftmailer.transport.buffer'], [$app['swiftmailer.transport.authhandler']], $app['swiftmailer.transport.eventdispatcher']);
             $encryption = null;
             if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tls'])) {
                 $encryption = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);
             }
             $options = $app['swiftmailer.options'] = array_replace(['host' => $app['conf']->get(['registry', 'email', 'smtp-host']), 'port' => $app['conf']->get(['registry', 'email', 'smtp-port']), 'username' => $app['conf']->get(['registry', 'email', 'smtp-user']), 'password' => $app['conf']->get(['registry', 'email', 'smtp-password']), 'encryption' => $encryption, 'auth_mode' => null], $app['swiftmailer.options']);
             $transport->setHost($options['host']);
             $transport->setPort($options['port']);
             // tls or ssl
             $transport->setEncryption($options['encryption']);
             if ($app['conf']->get(['registry', 'email', 'smtp-auth-enabled'])) {
                 $transport->setUsername($options['username']);
                 $transport->setPassword($options['password']);
                 $transport->setAuthMode($options['auth_mode']);
             }
         } else {
             $transport = new \Swift_Transport_MailTransport(new \Swift_Transport_SimpleMailInvoker(), $app['swiftmailer.transport.eventdispatcher']);
         }
         return $transport;
     });
     $this['imagine.factory'] = $this->share(function (Application $app) {
         if ($app['conf']->get(['registry', 'executables', 'imagine-driver']) != '') {
             return $app['conf']->get(['registry', 'executables', 'imagine-driver']);
         }
         if (class_exists('\\Gmagick')) {
             return 'gmagick';
         }
         if (class_exists('\\Imagick')) {
             return 'imagick';
         }
         if (extension_loaded('gd')) {
             return 'gd';
         }
         throw new \RuntimeException('No Imagine driver available');
     });
     $app = $this;
     $this['phraseanet.logger'] = $this->protect(function ($databox) use($app) {
         try {
             return \Session_Logger::load($app, $databox);
         } catch (\Exception_Session_LoggerNotFound $e) {
             return \Session_Logger::create($app, $databox, $app['browser']);
         }
     });
     $this['date-formatter'] = $this->share(function (Application $app) {
         return new \phraseadate($app);
     });
     $this['xpdf.pdftotext'] = $this->share($this->extend('xpdf.pdftotext', function (PdfToText $pdftotext, Application $app) {
         if ($app['conf']->get(['registry', 'executables', 'pdf-max-pages'])) {
             $pdftotext->setPageQuantity($app['conf']->get(['registry', 'executables', 'pdf-max-pages']));
         }
         return $pdftotext;
     }));
     $this['dispatcher'] = $this->share($this->extend('dispatcher', function ($dispatcher, Application $app) {
         $dispatcher->addListener(KernelEvents::REQUEST, [$app, 'initSession'], 254);
         $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128);
         $dispatcher->addSubscriber(new LogoutSubscriber());
         $dispatcher->addSubscriber(new PhraseaLocaleSubscriber($app));
         $dispatcher->addSubscriber(new MaintenanceSubscriber($app));
         $dispatcher->addSubscriber(new CookiesDisablerSubscriber($app));
         return $dispatcher;
     }));
     $this['log.channels'] = ['monolog', 'task-manager.logger'];
     $this->register(new LocaleServiceProvider());
     $this->mount('/include/minify/', new Minifier());
     $this->mount('/permalink/', new Permalink());
     $this->mount('/lightbox/', new Lightbox());
     $app['plugins.directory'] = $app->share(function () {
         $dir = __DIR__ . '/../../../plugins';
         if (is_dir($dir)) {
             return realpath($dir);
         }
         return $dir;
     });
 }
Beispiel #12
0
 private function registerEmailServices(Application $app)
 {
     $emailConfig = $this->config['notifications']['email'];
     $app['devture_nagios.notification.email.sender_email_address'] = $emailConfig['sender_email_address'];
     $app['devture_nagios.notification.email.transport.auth_handler'] = $app->share(function () {
         return new \Swift_Transport_Esmtp_AuthHandler(array(new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()));
     });
     $app['devture_nagios.notification.email.transport.buffer'] = $app->share(function () {
         return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory());
     });
     $app['devture_nagios.notification.email.transport.event_dispatcher'] = $app->share(function () {
         return new \Swift_Events_SimpleEventDispatcher();
     });
     $app['devture_nagios.notification.email.transport'] = $app->share(function ($app) use($emailConfig) {
         $transport = new \Swift_Transport_EsmtpTransport($app['devture_nagios.notification.email.transport.buffer'], array($app['devture_nagios.notification.email.transport.auth_handler']), $app['devture_nagios.notification.email.transport.event_dispatcher']);
         $transport->setHost($emailConfig['host']);
         $transport->setPort($emailConfig['port']);
         $transport->setUsername($emailConfig['username']);
         $transport->setPassword($emailConfig['password']);
         $transport->setEncryption($emailConfig['encryption']);
         $transport->setAuthMode($emailConfig['auth_mode']);
         return $transport;
     });
     $app['devture_nagios.notification.email.mailer'] = $app->share(function ($app) {
         return new \Swift_Mailer($app['devture_nagios.notification.email.transport']);
     });
 }
 /**
  * Gets the 'swiftmailer.transport.real' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return Swift_Transport_EsmtpTransport A Swift_Transport_EsmtpTransport instance.
  */
 protected function getSwiftmailer_Transport_RealService()
 {
     $this->services['swiftmailer.transport.real'] = $instance = new \Swift_Transport_EsmtpTransport(new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()), array(0 => new \Swift_Transport_Esmtp_AuthHandler(array(0 => new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), 1 => new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), 2 => new \Swift_Transport_Esmtp_Auth_PlainAuthenticator()))), $this->get('swiftmailer.transport.eventdispatcher'));
     $instance->setHost('smtp.gmail.com');
     $instance->setPort(465);
     $instance->setEncryption('ssl');
     $instance->setUsername('*****@*****.**');
     $instance->setPassword('sleeper16');
     $instance->setAuthMode('login');
     $instance->setTimeout(30);
     $instance->setSourceIp(NULL);
     return $instance;
 }