Ejemplo n.º 1
0
 protected function convertMailMessage($mail)
 {
     if (!$mail instanceof \Zend_Mail) {
         throw new \InvalidArgumentException('The message should be an instance of \\Zend_Mail');
     }
     //convert zend_mail1 to zend\mail\message
     // \Zend_Debug::dump($mail->getFrom());
     // \Zend_Debug::dump(get_class_methods($mail));
     // \Zend_Debug::dump($mail->getHeader('To'));
     // \Zend_Debug::dump($mail->getHeaders());
     $headers = new \Zend\Mail\Headers();
     $_headers = [];
     foreach ($mail->getHeaders() as $headerName => $values) {
         foreach ($values as $key => $value) {
             if ($key !== 'append') {
                 $_headers[$headerName][$key] = $value;
             }
         }
     }
     $headers->addHeaders($_headers);
     $headersEncoding = $mail->getHeaderEncoding();
     $headers->setEncoding($headersEncoding);
     $_message = new \Zend\Mail\Message();
     $_message->setHeaders($headers);
     $body = new \Zend\Mime\Message();
     $charset = $mail->getCharset();
     $text = $mail->getBodyText();
     if (!empty($text)) {
         if ($text instanceof \Zend_Mime_Part) {
             $part = new \Zend\Mime\Part($text->getContent());
             $part->encoding = $text->encoding;
             $part->type = $text->type;
             $part->charset = $text->charset;
         } elseif (is_string($text)) {
             $part = new \Zend\Mime\Part($text);
             $part->encoding = \Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
             $part->type = \Zend\Mime\Mime::TYPE_TEXT;
             $part->charset = $charset;
         }
         $body->addPart($part);
     }
     $html = $mail->getBodyHtml();
     if (!empty($html)) {
         if ($html instanceof \Zend_Mime_Part) {
             $part = new \Zend\Mime\Part($html->getContent());
             $part->encoding = $html->encoding;
             $part->type = $html->type;
             $part->charset = $html->charset;
         } elseif (is_string($html)) {
             $part = new \Zend\Mime\Part($html);
             $part->encoding = \Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
             $part->type = \Zend\Mime\Mime::TYPE_TEXT;
             $part->charset = $charset;
         }
         $body->addPart($part);
     }
     //@todo $mail->getParts() copy attachments
     $_message->setBody($body);
     // \Zend_Debug::dump($_message);
     // die;
     return $_message;
 }
Ejemplo n.º 2
0
return array('doctrine' => array('driver' => array('user_driver' => array('class' => 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver', 'paths' => array(__DIR__ . '/../src/User/Entity')), 'orm_default' => array('drivers' => array('User\\Entity' => 'user_driver'))), 'configuration' => array('orm_default' => array('types' => array('enumstatus' => 'User\\DBAL\\Types\\EnumStatusType'))), 'authentication' => array('orm_default' => array('object_manager' => 'Doctrine\\ORM\\EntityManager', 'identity_class' => 'User\\Entity\\Auth', 'identity_property' => 'foreignKey', 'credential_property' => 'token', 'credential_callable' => '\\User\\Service\\Auth::encrypt'))), 'router' => array('routes' => array('login' => array('type' => 'Literal', 'options' => array('route' => '/login', 'defaults' => array('__NAMESPACE__' => 'User\\Controller', 'controller' => 'Auth', 'action' => 'login')), 'may_terminate' => true), 'user' => array('type' => 'Literal', 'options' => array('route' => '/user', 'defaults' => array('__NAMESPACE__' => 'User\\Controller', 'controller' => 'index', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller[/:action[/:id]]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())), 'confirm' => array('type' => 'Segment', 'options' => array('route' => '/signup/confirm/:confirm', 'defaults' => array('controller' => 'signup', 'action' => 'confirm'))), 'recover-password' => array('type' => 'Segment', 'options' => array('route' => '/auth/recover-password/:hash', 'defaults' => array('controller' => 'auth', 'action' => 'recover-password'))))))), 'controllers' => array('invokables' => array('User\\Controller\\Signup' => 'User\\Controller\\SignupController', 'User\\Controller\\Auth' => 'User\\Controller\\AuthController', 'User\\Controller\\Mail' => 'User\\Controller\\MailController', 'User\\Controller\\Management' => 'User\\Controller\\ManagementController', 'User\\Controller\\Profile' => 'User\\Controller\\ProfileController')), 'view_manager' => array('template_path_stack' => array(__DIR__ . '/../view'), 'template_map' => array('error/403' => __DIR__ . '/../view/error/403.phtml')), 'service_manager' => array('factories' => array('Db\\Adapter' => 'Zend\\Db\\Adapter\\AdapterServiceFactory', 'Zend\\Authentication\\AuthenticationService' => function ($serviceManager) {
    // If you are using DoctrineORMModule
    return $serviceManager->get('doctrine.authenticationservice.orm_default');
}, 'User\\Service\\User' => function ($sm) {
    return new User\Service\User($sm);
}, 'User\\Service\\Auth' => function ($sm) {
    return new User\Service\Auth($sm);
}, 'User\\Provider\\Identity\\DoctrineProvider' => function ($sm) {
    $entityManager = $sm->get('Doctrine\\ORM\\EntityManager');
    $authService = $sm->get('Zend\\Authentication\\AuthenticationService');
    $doctrineProvider = new User\Provider\Identity\DoctrineProvider($entityManager, $authService);
    $doctrineProvider->setServiceLocator($sm);
    $config = $sm->get('BjyAuthorize\\Config');
    $doctrineProvider->setDefaultRole($config['default_role']);
    return $doctrineProvider;
}, 'mail.transport' => function (\Zend\ServiceManager\ServiceManager $serviceManager) {
    $config = $serviceManager->get('Config');
    $transport = new \Zend\Mail\Transport\Smtp();
    $transport->setOptions(new \Zend\Mail\Transport\SmtpOptions($config['mail']['transport']['options']));
    return $transport;
    //return smtp transport...
}, 'mail.message' => function (\Zend\ServiceManager\ServiceManager $serviceManager) {
    $config = $serviceManager->get('Config');
    $message = new \Zend\Mail\Message();
    $headers = new \Zend\Mail\Headers();
    $headers->addHeaders($config['mail']['message']['headers']);
    $message->setHeaders($headers)->setFrom($config['mail']['message']['from']);
    //uncomment this if you want send email around
    //$message->getHeaders()->addHeaderLine('EXTERNAL', 'true');
    return $message;
})), 'bjyauthorize' => array('guards' => array('BjyAuthorize\\Guard\\Controller' => array(array('controller' => 'User\\Controller\\Auth', 'action' => array('twitter', 'twitter-callback', 'facebook', 'facebook-callback'), 'roles' => array('guest', 'user')), array('controller' => 'User\\Controller\\Auth', 'action' => array('login', 'recover-password'), 'roles' => array('guest')), array('controller' => 'User\\Controller\\Auth', 'action' => array('logout'), 'roles' => array('user')), array('controller' => 'User\\Controller\\Signup', 'action' => array('confirm'), 'roles' => array('guest', 'user')), array('controller' => 'User\\Controller\\Signup', 'action' => array('index', 'forgot-password'), 'roles' => array('guest')), array('controller' => 'User\\Controller\\Mail', 'action' => array('index'), 'roles' => array('admin')), array('controller' => 'User\\Controller\\Management', 'action' => array('create'), 'roles' => array('admin')), array('controller' => 'User\\Controller\\Management', 'action' => array('grid'), 'roles' => array('guest', 'user', 'admin')), array('controller' => 'User\\Controller\\Management', 'action' => array('get-users'), 'roles' => array('guest', 'user', 'admin')), array('controller' => 'User\\Controller\\Profile', 'roles' => array('user')), array('controller' => 'User\\Controller\\Management', 'action' => array('index'), 'roles' => array('admin')), array('controller' => 'User\\Controller\\Management', 'action' => array('edit'), 'roles' => array('admin')), array('controller' => 'User\\Controller\\Management', 'action' => array('delete'), 'roles' => array('admin'))))), 'navigation' => array('default' => array(array('label' => 'User', 'controller' => 'user', 'pages' => array(array('label' => 'Create', 'controller' => 'management', 'action' => 'create', 'route' => 'user/default', 'controller_namespace' => 'User\\Controller\\Management', 'module' => 'User'), array('label' => 'All', 'controller' => 'management', 'action' => 'index', 'route' => 'user/default', 'controller_namespace' => 'User\\Controller\\Management', 'module' => 'User'))))));