当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setImapConfiguration方法代码示例

本文整理汇总了PHP中Oro\Bundle\UserBundle\Entity\User::setImapConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setImapConfiguration方法的具体用法?PHP User::setImapConfiguration怎么用?PHP User::setImapConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\UserBundle\Entity\User的用法示例。


在下文中一共展示了User::setImapConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkAction

 /**
  * @Route("/connection/check", name="oro_imap_connection_check", methods={"POST"})
  */
 public function checkAction()
 {
     $responseCode = Codes::HTTP_BAD_REQUEST;
     $data = null;
     $id = $this->getRequest()->get('id', false);
     if (false !== $id) {
         $data = $this->getDoctrine()->getRepository('OroImapBundle:ImapEmailOrigin')->find($id);
     }
     $form = $this->createForm('oro_imap_configuration', null, ['csrf_protection' => false, 'validation_groups' => ['Check']]);
     $form->setData($data);
     $form->submit($this->getRequest());
     /** @var ImapEmailOrigin $origin */
     $origin = $form->getData();
     if ($form->isValid() && null !== $origin) {
         $config = new ImapConfig($origin->getHost(), $origin->getPort(), $origin->getSsl(), $origin->getUser(), $this->get('oro_security.encoder.mcrypt')->decryptData($origin->getPassword()));
         try {
             $connector = $this->get('oro_imap.connector.factory')->createImapConnector($config);
             $this->manager = new ImapEmailFolderManager($connector, $this->getDoctrine()->getManager(), $origin);
             $emailFolders = $this->manager->getFolders();
             $origin->setFolders($emailFolders);
             $user = new User();
             $user->setImapConfiguration($origin);
             $userForm = $this->get('oro_user.form.user');
             $userForm->setData($user);
             return $this->render('OroImapBundle:Connection:check.html.twig', ['form' => $userForm->createView()]);
         } catch (\Exception $e) {
             $this->get('logger')->critical('Unable to connect to IMAP server: ' . $e->getMessage(), ['exception' => $e]);
         }
     }
     return new Response('', $responseCode);
 }
开发者ID:gmoigneu,项目名称:platform,代码行数:34,代码来源:ConnectionController.php

示例2: checkAction

 /**
  * @Route("/connection/check", name="oro_imap_connection_check", methods={"POST"})
  */
 public function checkAction(Request $request)
 {
     $responseCode = Codes::HTTP_BAD_REQUEST;
     $data = null;
     $id = $request->get('id', false);
     if (false !== $id) {
         $data = $this->getDoctrine()->getRepository('OroImapBundle:UserEmailOrigin')->find($id);
     }
     $form = $this->createForm('oro_imap_configuration', null, ['csrf_protection' => false]);
     $form->setData($data);
     $form->submit($request);
     /** @var UserEmailOrigin $origin */
     $origin = $form->getData();
     if ($form->isValid() && null !== $origin) {
         $response = [];
         $password = $this->get('oro_security.encoder.mcrypt')->decryptData($origin->getPassword());
         if ($origin->getImapHost() !== null) {
             $response['imap'] = [];
             $config = new ImapConfig($origin->getImapHost(), $origin->getImapPort(), $origin->getImapEncryption(), $origin->getUser(), $password);
             try {
                 $connector = $this->get('oro_imap.connector.factory')->createImapConnector($config);
                 $this->manager = new ImapEmailFolderManager($connector, $this->getDoctrine()->getManager(), $origin);
                 $emailFolders = $this->manager->getFolders();
                 $origin->setFolders($emailFolders);
                 if ($request->get('for_entity', 'user') === 'user') {
                     $user = new User();
                     $user->setImapConfiguration($origin);
                     $userForm = $this->get('oro_user.form.user');
                     $userForm->setData($user);
                     $response['imap']['folders'] = $this->renderView('OroImapBundle:Connection:check.html.twig', ['form' => $userForm->createView()]);
                 } elseif ($request->get('for_entity', 'user') === 'mailbox') {
                     $mailbox = new Mailbox();
                     $mailbox->setOrigin($origin);
                     $mailboxForm = $this->createForm('oro_email_mailbox');
                     $mailboxForm->setData($mailbox);
                     $response['imap']['folders'] = $this->renderView('OroImapBundle:Connection:checkMailbox.html.twig', ['form' => $mailboxForm->createView()]);
                 }
             } catch (\Exception $e) {
                 $response['imap']['error'] = $e->getMessage();
             }
         }
         if ($origin->getSmtpHost() !== null) {
             $response['smtp'] = [];
             try {
                 $mailer = $this->get('oro_email.direct_mailer');
                 $transport = $mailer->getTransport();
                 $transport->setHost($origin->getSmtpHost());
                 $transport->setPort($origin->getSmtpPort());
                 $transport->setEncryption($origin->getSmtpEncryption());
                 $transport->setUsername($origin->getUser());
                 $transport->setPassword($password);
                 $transport->start();
             } catch (\Exception $e) {
                 $response['smtp']['error'] = $e->getMessage();
             }
         }
         return new JsonResponse($response);
     }
     return new Response('', $responseCode);
 }
开发者ID:2ndkauboy,项目名称:platform,代码行数:63,代码来源:ConnectionController.php

示例3: testImapConfiguration

 public function testImapConfiguration()
 {
     $entity = new User();
     $imapConfiguration = new ImapEmailOrigin();
     $this->assertEmpty($entity->getImapConfiguration());
     $entity->setImapConfiguration($imapConfiguration);
     $this->assertEquals($imapConfiguration, $entity->getImapConfiguration());
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:8,代码来源:UserTest.php

示例4: testImapConfiguration

 public function testImapConfiguration()
 {
     $entity = new User();
     $imapConfiguration = $this->getMock('Oro\\Bundle\\ImapBundle\\Entity\\ImapEmailOrigin');
     $imapConfiguration->expects($this->once())->method('setIsActive')->with(false);
     $this->assertCount(0, $entity->getEmailOrigins());
     $this->assertNull($entity->getImapConfiguration());
     $entity->setImapConfiguration($imapConfiguration);
     $this->assertEquals($imapConfiguration, $entity->getImapConfiguration());
     $this->assertCount(1, $entity->getEmailOrigins());
     $entity->setImapConfiguration(null);
     $this->assertNull($entity->getImapConfiguration());
     $this->assertCount(0, $entity->getEmailOrigins());
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:UserTest.php


注:本文中的Oro\Bundle\UserBundle\Entity\User::setImapConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。