當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。