src/Loggers/SwiftMailerHandlerFactory.php
/**
     * Creates a new formatter instance based on the passed configuration.
     *
     * @param \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration The handler configuration
     *
     * @return \Monolog\Handler\HandlerInterface The handler instance
     */
Creates a new formatter instance based on the passed configuration.

@return \Monolog\Handler\HandlerInterface The handler instance
Creates a new formatter instance based on the passed configuration . @return \ Monolog \ Handler \ HandlerInterface The handler instance
public function factory(HandlerConfigurationInterface $handlerConfiguration)
    {
        $swiftMailerConfiguration = $handlerConfiguration->getSwiftMailer();
        $possibleSwiftMailer = $this->getContainer()->get($swiftMailerConfiguration->getId());
        if ($possibleSwiftMailer instanceof TransportMailerFactoryInterface) {
            $swiftMailer = $possibleSwiftMailer->factory($swiftMailerConfiguration->getTransport());
        } else {
            $swiftMailer = $possibleSwiftMailer;
        }
        $bubble = $handlerConfiguration->getParam(LoggerKeys::BUBBLE);
        $logLevel = $handlerConfiguration->getParam(LoggerKeys::LOG_LEVEL);
        $to = $swiftMailerConfiguration->getParam(SwiftMailerKeys::TO);
        $from = $swiftMailerConfiguration->getParam(SwiftMailerKeys::FROM);
        $subject = $swiftMailerConfiguration->getParam(SwiftMailerKeys::SUBJECT);
        $contentType = $swiftMailerConfiguration->getParam(SwiftMailerKeys::CONTENT_TYPE);
        $message = $swiftMailer->createMessage()
            ->setSubject(sprintf('[%s] %s', $this->getSystemName(), $subject))
            ->setFrom($from)
            ->setTo($to)
            ->setBody('', $contentType);
        $reflectionClass = new \ReflectionClass(SwiftMailerHandler::class);
        return $reflectionClass->newInstanceArgs(array($swiftMailer, $message, $logLevel, $bubble));
    }
public function factory ( HandlerConfigurationInterface $ handlerConfiguration ) { $ swiftMailerConfiguration = $ handlerConfiguration -> getSwiftMailer ( ) ; $ possibleSwiftMailer = $ this -> getContainer ( ) -> get ( $ swiftMailerConfiguration -> getId ( ) ) ; if ( $ possibleSwiftMailer instanceof TransportMailerFactoryInterface ) { $ swiftMailer = $ possibleSwiftMailer -> factory ( $ swiftMailerConfiguration -> getTransport ( ) ) ; } else { $ swiftMailer = $ possibleSwiftMailer ; } $ bubble = $ handlerConfiguration -> getParam ( LoggerKeys :: BUBBLE ) ; $ logLevel = $ handlerConfiguration -> getParam ( LoggerKeys :: LOG_LEVEL ) ; $ to = $ swiftMailerConfiguration -> getParam ( SwiftMailerKeys :: TO ) ; $ from = $ swiftMailerConfiguration -> getParam ( SwiftMailerKeys :: FROM ) ; $ subject = $ swiftMailerConfiguration -> getParam ( SwiftMailerKeys :: SUBJECT ) ; $ contentType = $ swiftMailerConfiguration -> getParam ( SwiftMailerKeys :: CONTENT_TYPE ) ; $ message = $ swiftMailer -> createMessage ( ) -> setSubject ( sprintf ( '[%s] %s' , $ this -> getSystemName ( ) , $ subject ) ) -> setFrom ( $ from ) -> setTo ( $ to ) -> setBody ( '' , $ contentType ) ; $ reflectionClass = new \ ReflectionClass ( SwiftMailerHandler :: class ) ; return $ reflectionClass -> newInstanceArgs ( array ( $ swiftMailer , $ message , $ logLevel , $ bubble ) ) ; }
Creates a new formatter instance based on the passed configuration.
Creates a new formatter instance based on the passed configuration .
// load the swift mailer configuration // create the swift mailer (factory) instance // query whether or not we've a factory or the instance /** @var \Swift_Mailer $swiftMailer */ // load the generic logger configuration // load sender/receiver configuration // initialize the message template // initialize the handler node