本文整理汇总了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);
}
示例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);
}
示例3: testImapConfiguration
public function testImapConfiguration()
{
$entity = new User();
$imapConfiguration = new ImapEmailOrigin();
$this->assertEmpty($entity->getImapConfiguration());
$entity->setImapConfiguration($imapConfiguration);
$this->assertEquals($imapConfiguration, $entity->getImapConfiguration());
}
示例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());
}