本文整理汇总了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);
}
示例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();
}
示例3: getUser
/**
* @return User
*/
protected function getUser()
{
if (!self::$user) {
self::$user = new User();
self::$user->setOrganization(new Organization());
}
return self::$user;
}
示例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;
}
示例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);
}
示例6: testOrganization
public function testOrganization()
{
$entity = new User();
$organization = new Organization();
$this->assertNull($entity->getOrganization());
$entity->setOrganization($organization);
$this->assertSame($organization, $entity->getOrganization());
}