本文整理汇总了PHP中Oro\Bundle\UserBundle\Entity\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getBusinessUnitsTree
/**
* Build business units tree for user page
*
* @param User $user
* @return array
*/
public function getBusinessUnitsTree(User $user = null)
{
$businessUnits = $this->createQueryBuilder('businessUnit')->select(array('businessUnit.id', 'businessUnit.name', 'IDENTITY(businessUnit.owner) parent'));
if ($user && $user->getId()) {
$units = $user->getBusinessUnits()->map(function (BusinessUnit $businessUnit) {
return $businessUnit->getId();
});
$units = $units->toArray();
if ($units) {
$businessUnits->addSelect('CASE WHEN businessUnit.id IN (:userUnits) THEN 1 ELSE 0 END as hasUser');
$businessUnits->setParameter(':userUnits', $units);
}
}
$businessUnits = $businessUnits->getQuery()->getArrayResult();
$children = array();
foreach ($businessUnits as &$businessUnit) {
$parent = $businessUnit['parent'] ?: 0;
$children[$parent][] =& $businessUnit;
}
unset($businessUnit);
foreach ($businessUnits as &$businessUnit) {
if (isset($children[$businessUnit['id']])) {
$businessUnit['children'] = $children[$businessUnit['id']];
}
}
unset($businessUnit);
if (isset($children[0])) {
$children = $children[0];
}
return $children;
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:37,代码来源:BusinessUnitRepository.php
示例2: 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
示例3: 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
示例4: 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
示例5: testAddRemoveActivityOwner
/**
* Test add and remove activity owner from ActivityList
*/
public function testAddRemoveActivityOwner()
{
$activity = new ActivityList();
$activity->setId(1);
$organization = new Organization();
$user1 = new User();
$user1->setId(1);
$user1->setFirstName('TestUserName1');
$entity1 = new ActivityOwner();
$entity1->setActivity($activity);
$entity1->setUser($user1);
$entity1->setOrganization($organization);
$activity->addActivityOwner($entity1);
$user2 = new User();
$user1->setId(2);
$user2->setFirstName('TestUserName2');
$entity2 = new ActivityOwner();
$entity2->setActivity($activity);
$entity2->setUser($user2);
$entity2->setOrganization($organization);
$activity->addActivityOwner($entity2);
$this->assertTrue($activity->getActivityOwners()->contains($entity1));
$this->assertTrue($activity->getActivityOwners()->contains($entity2));
$activity->removeActivityOwner($entity1);
$activity->removeActivityOwner($entity2);
$this->assertFalse($activity->getActivityOwners()->contains($entity1));
$this->assertFalse($activity->getActivityOwners()->contains($entity2));
}
开发者ID:Maksold,项目名称:platform,代码行数:31,代码来源:ActivityOwnerTest.php
示例6: testProcessValidData
public function testProcessValidData()
{
$appendedUser = new User();
$appendedUser->setId(1);
$removedUser = new User();
$removedUser->setId(2);
$removedUser->addBusinessUnit($this->entity);
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$appendForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$appendForm->expects($this->once())->method('getData')->will($this->returnValue(array($appendedUser)));
$this->form->expects($this->at(3))->method('get')->with('appendUsers')->will($this->returnValue($appendForm));
$removeForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$removeForm->expects($this->once())->method('getData')->will($this->returnValue(array($removedUser)));
$this->form->expects($this->at(4))->method('get')->with('removeUsers')->will($this->returnValue($removeForm));
$this->manager->expects($this->at(0))->method('persist')->with($appendedUser);
$this->manager->expects($this->at(1))->method('persist')->with($removedUser);
$this->manager->expects($this->at(2))->method('persist')->with($this->entity);
$this->manager->expects($this->once())->method('flush');
$this->assertTrue($this->handler->process($this->entity));
$businessUnits = $appendedUser->getBusinessUnits()->toArray();
$this->assertCount(1, $businessUnits);
$this->assertEquals($this->entity, current($businessUnits));
$this->assertCount(0, $removedUser->getBusinessUnits()->toArray());
}
开发者ID:Maksold,项目名称:platform,代码行数:27,代码来源:BusinessUnitHandlerTest.php
示例7: testOnFlushUpdateUser
/**
* Test existing user modification
*/
public function testOnFlushUpdateUser()
{
$args = new OnFlushEventArgs($this->em);
$user = new User();
$org = new Organization();
$org->setId(1);
$org->setName('test');
$user->addOrganization($org);
$newCalendar = new Calendar();
$newCalendar->setOwner($user);
$newCalendar->setOrganization($org);
$newConnection = new CalendarConnection($newCalendar);
$newCalendar->addConnection($newConnection);
$calendarMetadata = new ClassMetadata(get_class($newCalendar));
$connectionMetadata = new ClassMetadata(get_class($newConnection));
$this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValueMap([['Oro\\Bundle\\CalendarBundle\\Entity\\Calendar', $calendarMetadata], ['Oro\\Bundle\\CalendarBundle\\Entity\\CalendarConnection', $connectionMetadata]]));
$calendarRepo = $this->getMockBuilder('\\Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$calendarRepo->expects($this->any())->method('findDefaultCalendar')->will($this->returnValue(false));
$this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->uow));
$this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([]));
$this->uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue([$user]));
$this->em->expects($this->any())->method('getRepository')->with('OroCalendarBundle:Calendar')->will($this->returnValue($calendarRepo));
$this->em->expects($this->at(2))->method('persist')->with($this->equalTo($newCalendar));
$this->em->expects($this->at(3))->method('persist')->with($this->equalTo($newConnection));
$this->uow->expects($this->at(2))->method('computeChangeSet')->with($calendarMetadata, $newCalendar);
$this->uow->expects($this->at(3))->method('computeChangeSet')->with($connectionMetadata, $newConnection);
$this->listener->onFlush($args);
}
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:EntityListenerTest.php
示例8: testGetActivityOwners
public function testGetActivityOwners()
{
$organization = new Organization();
$organization->setName('Org');
$user = new User();
$user->setUsername('test');
$emailUser = new EmailUser();
$emailUser->setOrganization($organization);
$emailUser->setOwner($user);
$owners = [$emailUser];
$emailMock = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\EmailUser')->setMethods(['getFromEmailAddress', 'hasOwner', 'getOwner', 'getOrganization', 'getActivityTargetEntities'])->disableOriginalConstructor()->getMock();
$emailMock->expects($this->once())->method('getFromEmailAddress')->willReturn($emailMock);
$emailMock->expects($this->once())->method('getOwner')->willReturn($emailMock);
$emailMock->expects($this->exactly(2))->method('getOrganization')->willReturn($organization);
$emailMock->expects($this->exactly(1))->method('getActivityTargetEntities')->willReturn([]);
$activityListMock = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\ActivityList')->disableOriginalConstructor()->getMock();
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$this->doctrineRegistryLink->expects($this->once())->method('getService')->willReturn($em);
$em->expects($this->once())->method('getRepository')->willReturn($repository);
$repository->expects($this->once())->method('findBy')->willReturn($owners);
$activityOwnerArray = $this->emailActivityListProvider->getActivityOwners($emailMock, $activityListMock);
$this->assertCount(1, $activityOwnerArray);
$owner = $activityOwnerArray[0];
$this->assertEquals($organization->getName(), $owner->getOrganization()->getName());
$this->assertEquals($user->getUsername(), $owner->getUser()->getUsername());
}
开发者ID:antrampa,项目名称:platform,代码行数:27,代码来源:EmailActivityListProviderTest.php
示例9: createGridViewLabel
/**
* @param User $currentUser
* @param GridView $gridView
*
* @return string
*/
protected function createGridViewLabel(User $currentUser, GridView $gridView)
{
if ($gridView->getOwner()->getId() === $currentUser->getId()) {
return $gridView->getName();
}
return $this->translator->trans('oro.datagrid.gridview.shared_by', ['%name%' => $gridView->getName(), '%owner%' => $gridView->getOwner()->getUsername()]);
}
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:GridViewsLoadListener.php
示例10: setCurrentStatus
/**
* Set status as current
*
* @param User $user
* @param Status $status
* @param bool $reloadUser
*/
public function setCurrentStatus(User $user, Status $status = null, $reloadUser = true)
{
$user->setCurrentStatus($status);
$this->um->updateUser($user);
if ($reloadUser) {
$this->um->reloadUser($user);
}
}
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:StatusManager.php
示例11: updatePassword
/**
* Updates a user password if a plain password is set
*
* @param User $user
*/
public function updatePassword(User $user)
{
if (0 !== strlen($password = $user->getPlainPassword())) {
$encoder = $this->getEncoder($user);
$user->setPassword($encoder->encodePassword($password, $user->getSalt()));
$user->eraseCredentials();
}
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:UserManager.php
示例12: dataProvider
/**
* @return array
*/
public function dataProvider()
{
$object = new \stdClass();
$userDisabled = new User();
$userDisabled->setEnabled(false);
$userEnabled = new User();
return [[null, false], [$object, false], [$userDisabled, false], [$userEnabled, true]];
}
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:PlaceholderFilterTest.php
示例13: testToStringUsername
public function testToStringUsername()
{
$obj = new Calendar();
$owner = new User();
$owner->setUsername('testUsername');
$obj->setOwner($owner);
$this->assertEquals($owner->getUsername(), (string) $obj);
}
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:CalendarTest.php
示例14: testGet
/**
* @depends testCreate
* @param integer $id
* @return array
*/
public function testGet($id)
{
$result = $this->soapClient->getPartner($id);
$partner = $this->valueToArray($result);
$this->assertArrayIntersectEquals(['id' => $id, 'partnerCondition' => $this->partnerCreateData['partnerCondition'], 'status' => $this->partnerCreateData['status'], 'account' => $this->getReference('orocrm_partner:test_account_1')->getId(), 'owner' => $this->adminUser->getId()], $partner);
$this->assertArrayHasKey('startDate', $partner);
$this->assertNotEmpty($partner['startDate']);
return $partner;
}
开发者ID:rodolfobandeira,项目名称:training-crm-application,代码行数:14,代码来源:PartnerControllerTest.php
示例15: testSetUsername
public function testSetUsername()
{
$user = new User();
$user->setUsername('testuser');
$this->loggableManager->setUsername($user);
$this->setExpectedException('InvalidArgumentException', 'Username must be a string, or object should have method: getUsername');
$wrongUser = new \stdClass();
$this->loggableManager->setUsername($wrongUser);
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:9,代码来源:LoggableManagerTest.php
示例16: isCurrentUser
/**
* Returns true if passed user is currently authenticated
*
* @param User $user
* @return bool
*/
protected function isCurrentUser(User $user)
{
$token = $this->security->getToken();
$currentUser = $token ? $token->getUser() : null;
if ($user->getId() && is_object($currentUser)) {
return $currentUser->getId() == $user->getId();
}
return false;
}
开发者ID:xamin123,项目名称:platform,代码行数:15,代码来源:UserSubscriber.php
示例17: assignBusinessUnits
/**
* @param User $entity
* @param array $businessUnits
*/
public function assignBusinessUnits($entity, array $businessUnits)
{
if ($businessUnits) {
$businessUnits = $this->getBusinessUnitRepo()->getBusinessUnits($businessUnits);
} else {
$businessUnits = new ArrayCollection();
}
$entity->setBusinessUnits($businessUnits);
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:BusinessUnitManager.php
示例18: testInitializeScopeId
public function testInitializeScopeId()
{
$user = new User();
$user->setId(123);
$token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
$this->securityContext->expects($this->once())->method('getToken')->willReturn($token);
$token->expects($this->once())->method('getUser')->willReturn($user);
$this->assertEquals(123, $this->manager->getScopeId());
}
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:UserScopeManagerTest.php
示例19: testGetPermissionsWithEntities
public function testGetPermissionsWithEntities()
{
$this->client->request('GET', $this->getUrl('oro_api_get_user_permissions', ['id' => $this->user->getId(), 'entities' => 'Oro\\Bundle\\UserBundle\\Entity\\User']));
$result = $this->getJsonResponseContent($this->client->getResponse(), 200);
$this->assertCount(1, $result, "Result should contains only permissions for one entity");
$this->client->request('GET', $this->getUrl('oro_api_get_user_permissions', ['id' => $this->user->getId(), 'entities' => implode(',', ['user', 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'])]));
$result = $this->getJsonResponseContent($this->client->getResponse(), 200);
$this->assertCount(2, $result, "Result should contains only permissions for two entities");
}
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:RestPermissionsTest.php
示例20: addDefaultGroup
/**
* Add the default group to the user.
*
* @param User $user
*
* @throws \RuntimeException
*/
protected function addDefaultGroup(User $user)
{
if (!$user->hasGroup(User::GROUP_DEFAULT)) {
$group = $this->manager->getStorageManager()->getRepository('OroUserBundle:Group')->getDefaultUserGroup();
if (!$group) {
throw new \RuntimeException('Default user group not found');
}
$user->addGroup($group);
}
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:UserHandler.php
注:本文中的Oro\Bundle\UserBundle\Entity\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论