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


PHP User::setOrganization方法代码示例

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


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

示例1: testOnFlushCreateUser

 /**
  * Test new user creation
  */
 public function testOnFlushCreateUser()
 {
     $args = new OnFlushEventArgs($this->em);
     $user = new User();
     $org1 = new Organization();
     ReflectionUtil::setId($org1, 1);
     $org2 = new Organization();
     ReflectionUtil::setId($org2, 2);
     $user->setOrganization($org1);
     $user->addOrganization($org1);
     $user->addOrganization($org2);
     $newCalendar1 = new Calendar();
     $newCalendar1->setOwner($user)->setOrganization($org1);
     $newCalendar2 = new Calendar();
     $newCalendar2->setOwner($user)->setOrganization($org2);
     $calendarMetadata = new ClassMetadata(get_class($newCalendar1));
     $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([$user]));
     $this->uow->expects($this->once())->method('getScheduledCollectionUpdates')->will($this->returnValue([]));
     $this->em->expects($this->at(1))->method('persist')->with($this->equalTo($newCalendar1));
     $this->em->expects($this->at(2))->method('getClassMetadata')->with('Oro\\Bundle\\CalendarBundle\\Entity\\Calendar')->will($this->returnValue($calendarMetadata));
     $this->em->expects($this->at(3))->method('persist')->with($this->equalTo($newCalendar2));
     $this->uow->expects($this->at(1))->method('computeChangeSet')->with($calendarMetadata, $newCalendar1);
     $this->uow->expects($this->at(2))->method('computeChangeSet')->with($calendarMetadata, $newCalendar2);
     $this->listener->onFlush($args);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:28,代码来源:EntityListenerTest.php

示例2: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var UserManager $userManager */
     $userManager = $this->container->get('oro_user.manager');
     $role = $manager->getRepository('OroUserBundle:Role')->findOneByRole('ROLE_ADMINISTRATOR');
     $group = $manager->getRepository('OroUserBundle:Group')->findOneByName('Administrators');
     $unit = $manager->getRepository('OroOrganizationBundle:BusinessUnit')->findOneByName('Main');
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $user = new User();
     $user->setUsername('owner_User');
     $user->addGroup($group);
     $user->addRole($role);
     $user->addBusinessUnit($unit);
     $user->setFirstname('Test Owner  FirstName');
     $user->setLastname('Test Owner LastName');
     $user->setEmail('owner@example.com');
     $user->setOwner($unit);
     $user->addGroup($group);
     $user->setPlainPassword('test password');
     $user->setSalt(md5(mt_rand(1, 222)));
     $user->setOrganization($organization);
     $userManager->updateUser($user);
     $this->setReference('owner_user', $user);
     $manager->flush();
 }
开发者ID:antrampa,项目名称:crm,代码行数:28,代码来源:LoadOwnerUser.php

示例3: getUser

 /**
  * @return User
  */
 protected function getUser()
 {
     if (!self::$user) {
         self::$user = new User();
         self::$user->setOrganization(new Organization());
     }
     return self::$user;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:11,代码来源:RequestCreateQuoteHandlerTest.php

示例4: createUser

 /**
  * @param string $firstName
  * @param string $lastName
  *
  * @return User
  */
 protected function createUser($firstName, $lastName)
 {
     $user = new User();
     $user->setOrganization($this->organization);
     $user->setFirstName($firstName);
     $user->setLastName($lastName);
     $user->setUsername(strtolower($firstName . '.' . $lastName));
     $user->setPassword(strtolower($firstName . '.' . $lastName));
     $user->setEmail(strtolower($firstName . '_' . $lastName . '@example.com'));
     $user->addEmail($this->email);
     $this->em->persist($user);
     return $user;
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:LoadEmailSuggestionData.php

示例5: 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);
                 $entity = $request->get('for_entity', 'user');
                 $organizationId = $request->get('organization');
                 $organization = $this->getOrganization($organizationId);
                 if ($entity === 'user') {
                     $user = new User();
                     $user->setImapConfiguration($origin);
                     $user->setOrganization($organization);
                     $userForm = $this->get('oro_user.form.user');
                     $userForm->setData($user);
                     $response['imap']['folders'] = $this->renderView('OroImapBundle:Connection:check.html.twig', ['form' => $userForm->createView()]);
                 } elseif ($entity === 'mailbox') {
                     $mailbox = new Mailbox();
                     $mailbox->setOrigin($origin);
                     if ($organization) {
                         $mailbox->setOrganization($organization);
                     }
                     $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 {
                 /** @var DirectMailer $mailer */
                 $mailer = $this->get('oro_email.direct_mailer');
                 // Prepare Smtp Transport
                 $mailer->prepareSmtpTransport($origin);
                 $transport = $mailer->getTransport();
                 $transport->start();
             } catch (\Exception $e) {
                 $response['smtp']['error'] = $e->getMessage();
             }
         }
         return new JsonResponse($response);
     }
     return new Response('', $responseCode);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:68,代码来源:ConnectionController.php

示例6: testOrganization

 public function testOrganization()
 {
     $entity = new User();
     $organization = new Organization();
     $this->assertNull($entity->getOrganization());
     $entity->setOrganization($organization);
     $this->assertSame($organization, $entity->getOrganization());
 }
开发者ID:xamin123,项目名称:platform,代码行数:8,代码来源:UserTest.php


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