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


PHP SecurityFacade::getLoggedUser方法代码示例

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


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

示例1: getRecipients

 /**
  * @param object $object
  * @param int $depth
  * @param bool $ignoreAcl
  * @param Organization|null $organization
  *
  * @return Recipient[]
  */
 public function getRecipients($object, $depth = 1, $ignoreAcl = false, Organization $organization = null)
 {
     $recipients = [];
     if ($this->isAccessDenyForOrganization($object, $ignoreAcl, $organization)) {
         return $recipients;
     }
     if (!$depth || ($ignoreAcl || !$this->securityFacade->isGranted('VIEW', $object))) {
         if (!$depth || $this->securityFacade->getLoggedUser() !== $object) {
             return $recipients;
         }
     }
     $className = ClassUtils::getClass($object);
     $metadata = $this->getMetadata($className);
     $attributes = $this->initAttributes($className, $metadata);
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (in_array('Oro\\Bundle\\EmailBundle\\Entity\\EmailInterface', class_implements($assoc['targetEntity']), true)) {
             $attributes[] = new EmailAttribute($name, true);
         } else {
             if ($depth > 1) {
                 $assocObject = $this->getPropertyAccessor()->getValue($object, $name);
                 if (!$assocObject instanceof \Traversable && !is_array($assocObject)) {
                     if ($assocObject) {
                         $assocObject = [$assocObject];
                     } else {
                         $assocObject = [];
                     }
                 }
                 foreach ($assocObject as $obj) {
                     $recipients = array_merge($recipients, $this->getRecipients($obj, $depth - 1, false, $organization));
                 }
             }
         }
     }
     return array_merge($recipients, $this->createRecipientsFromEmails($this->createEmailsFromAttributes($attributes, $object), $object, $metadata));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:43,代码来源:RelatedEmailsProvider.php

示例2: onSuccess

 /**
  * {@inheritDoc}
  * @throws \Doctrine\DBAL\ConnectionException
  */
 protected function onSuccess(AbstractRole $role, array $appendUsers, array $removeUsers)
 {
     // TODO: When task BB-1046 will be done, remove method removeOriginalRoleFromUsers.
     // In method addNewRoleToUsers before addRole add method removeRole($role). Also needs delete flush;
     /** @var AccountUserRole $role */
     if ($role->getId()) {
         /** @var AccountUserRoleRepository $roleRepository */
         $roleRepository = $this->doctrineHelper->getEntityRepository($role);
         $this->appendUsers = $roleRepository->getAssignedUsers($role);
     }
     $this->loggedAccountUser = $this->securityFacade->getLoggedUser();
     /** @var EntityManager $manager */
     $manager = $this->managerRegistry->getManagerForClass(ClassUtils::getClass($this->loggedAccountUser));
     $connection = $manager->getConnection();
     $connection->setTransactionIsolation(Connection::TRANSACTION_REPEATABLE_READ);
     $connection->beginTransaction();
     try {
         $this->removeOriginalRoleFromUsers($role, $manager);
         AclRoleHandler::onSuccess($this->newRole, $appendUsers, $removeUsers);
         $this->addNewRoleToUsers($role, $manager, $appendUsers, $removeUsers);
         $manager->flush();
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:31,代码来源:AccountUserRoleUpdateFrontendHandler.php

示例3: getEmailContext

 /**
  * Returns the context for the given email
  *
  * @param Email $email
  *
  * @return array
  */
 public function getEmailContext(Email $email)
 {
     $criteria = Criteria::create();
     $criteria->andWhere(Criteria::expr()->eq('id', $email->getId()));
     $qb = $this->activityManager->getActivityTargetsQueryBuilder($this->class, $criteria);
     if (null === $qb) {
         return [];
     }
     $result = $qb->getQuery()->getResult();
     if (empty($result)) {
         return $result;
     }
     $currentUser = $this->securityFacade->getLoggedUser();
     $currentUserClass = ClassUtils::getClass($currentUser);
     $currentUserId = $currentUser->getId();
     $result = array_values(array_filter($result, function ($item) use($currentUserClass, $currentUserId) {
         return !($item['entity'] === $currentUserClass && $item['id'] == $currentUserId);
     }));
     foreach ($result as &$item) {
         $route = $this->configManager->getEntityMetadata($item['entity'])->getRoute();
         $item['entityId'] = $email->getId();
         $item['targetId'] = $item['id'];
         $item['targetClassName'] = $this->entityClassNameHelper->getUrlSafeClassName($item['entity']);
         $item['icon'] = $this->configManager->getProvider('entity')->getConfig($item['entity'])->get('icon');
         $item['link'] = $route ? $this->router->generate($route, ['id' => $item['id']]) : null;
         unset($item['id'], $item['entity']);
     }
     return $result;
 }
开发者ID:nmallare,项目名称:platform,代码行数:36,代码来源:EmailApiEntityManager.php

示例4: postSet

 /**
  * Sets default data for create integrations form
  *
  * @param FormEvent $event
  */
 public function postSet(FormEvent $event)
 {
     $data = $event->getData();
     if ($data && !$data->getId() && !$data->getDefaultUserOwner() || null === $data) {
         $event->getForm()->get('defaultUserOwner')->setData($this->securityFacade->getLoggedUser());
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:DefaultUserOwnerSubscriber.php

示例5: process

 /**
  * Process form
  *
  * @param  CalendarEvent $entity
  * @throws \LogicException
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(CalendarEvent $entity)
 {
     if (!$entity->getCalendar()) {
         if ($this->securityFacade->getLoggedUser() && $this->securityFacade->getOrganization()) {
             /** @var Calendar $defaultCalendar */
             $defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($this->securityFacade->getLoggedUser()->getId(), $this->securityFacade->getOrganization()->getId());
             $entity->setCalendar($defaultCalendar);
         } else {
             throw new \LogicException('Current user did not define');
         }
     }
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
             if ($targetEntityClass) {
                 $targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
                 $targetEntity = $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId);
                 $action = $this->entityRoutingHelper->getAction($this->request);
                 if ($action === 'activity') {
                     $this->activityManager->addActivityTarget($entity, $targetEntity);
                 }
                 if ($action === 'assign' && $targetEntity instanceof User && $targetEntityId !== $this->securityFacade->getLoggedUserId()) {
                     /** @var Calendar $defaultCalendar */
                     $defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($targetEntity->getId(), $targetEntity->getOrganization()->getId());
                     $entity->setCalendar($defaultCalendar);
                 }
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
开发者ID:xamin123,项目名称:platform,代码行数:43,代码来源:CalendarEventHandler.php

示例6: onResultBefore

 /**
  * @param OrmResultBefore $event
  */
 public function onResultBefore(OrmResultBefore $event)
 {
     // listener logic is applied only to frontend part of application
     if ($this->securityFacade->getLoggedUser() instanceof User) {
         return;
     }
     $config = $event->getDatagrid()->getConfig();
     $query = $event->getQuery();
     /** @var Subselect|SelectStatement $select */
     $select = $query->getAST();
     $fromClause = $select instanceof SelectStatement ? $select->fromClause : $select->subselectFromClause;
     $skipAclCheck = true;
     /** @var IdentificationVariableDeclaration $identificationVariableDeclaration */
     foreach ($fromClause->identificationVariableDeclarations as $identificationVariableDeclaration) {
         $entityName = $identificationVariableDeclaration->rangeVariableDeclaration->abstractSchemaName;
         $metadata = $this->metadataProvider->getMetadata($entityName);
         if ($metadata->hasOwner()) {
             $skipAclCheck = false;
             break;
         }
     }
     if ($skipAclCheck) {
         $config->offsetSetByPath(Builder::DATASOURCE_SKIP_ACL_CHECK, true);
     }
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:28,代码来源:OrmDatasourceAclListener.php

示例7: getCurrentUser

 /**
  * @return User
  */
 protected function getCurrentUser()
 {
     $user = $this->securityFacade->getLoggedUser();
     if ($user instanceof User) {
         return $user;
     }
     return null;
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:GridViewsLoadListener.php

示例8: getLoggedUser

 /**
  * @return AccountUser|null
  */
 public function getLoggedUser()
 {
     $user = $this->securityFacade->getLoggedUser();
     if ($user instanceof AccountUser) {
         return $user;
     }
     return null;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:11,代码来源:AccountUserProvider.php

示例9: createChoices

 /**
  * @return array
  */
 protected function createChoices()
 {
     $user = $this->securityFacade->getLoggedUser();
     if (!$user instanceof User) {
         return [];
     }
     $emails = array_merge(array_values($this->relatedEmailsProvider->getEmails($user, 1, true)), $this->mailboxManager->findAvailableMailboxEmails($user, $this->securityFacade->getOrganization()));
     return array_combine($emails, $emails);
 }
开发者ID:snorchel,项目名称:platform,代码行数:12,代码来源:EmailAddressFromType.php

示例10: createChoices

 /**
  * @return array
  */
 protected function createChoices()
 {
     $user = $this->securityFacade->getLoggedUser();
     if (!$user instanceof User) {
         return [];
     }
     $emails = array_values($this->relatedEmailsProvider->getEmails($user, 1, true));
     return array_combine($emails, $emails);
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:EmailAddressFromType.php

示例11: getPrefix

 /**
  * @return string
  * @throws \RuntimeException
  */
 public function getPrefix()
 {
     $user = $this->securityFacade->getLoggedUser();
     if ($user instanceof User) {
         return self::BACKEND_PREFIX;
     } elseif ($user instanceof AccountUser) {
         return self::FRONTEND_PREFIX;
     }
     throw new \RuntimeException('This method must be called only for logged User or AccountUser');
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:RoleTranslationPrefixResolver.php

示例12: setSeenStatus

 /**
  * Set email seen status for current user for single email or thread
  *
  * @param Email $entity
  * @param bool  $isSeen
  * @param bool  $checkThread - if false it will be applied for single email instead of thread
  */
 public function setSeenStatus(Email $entity, $isSeen = true, $checkThread = false)
 {
     $user = $this->securityFacade->getLoggedUser();
     $organization = $this->securityFacade->getOrganization();
     $emailUsers = $this->getEmailUserRepository()->getAllEmailUsersByEmail($entity, $user, $organization, $checkThread);
     foreach ($emailUsers as $emailUser) {
         $this->setEmailUserSeen($emailUser, $isSeen);
     }
     $this->em->flush();
 }
开发者ID:ramunasd,项目名称:platform,代码行数:17,代码来源:EmailManager.php

示例13: getInvitationPermissions

 /**
  * @param ResultRecordInterface $record
  * @return array
  */
 public function getInvitationPermissions(ResultRecordInterface $record)
 {
     /** @var User $user */
     $user = $this->securityFacade->getLoggedUser();
     $invitationStatus = $record->getValue('invitationStatus');
     $parentId = $record->getValue('parentId');
     $ownerId = $record->getValue('ownerId');
     $childrenCount = $record->getValue('childrenCount');
     $isEditable = !$invitationStatus || $invitationStatus && !$parentId;
     return array('accept' => $this->isAvailableResponseButton($user, $parentId, $ownerId, $childrenCount, $invitationStatus, CalendarEvent::ACCEPTED), 'decline' => $this->isAvailableResponseButton($user, $parentId, $ownerId, $childrenCount, $invitationStatus, CalendarEvent::DECLINED), 'tentatively' => $this->isAvailableResponseButton($user, $parentId, $ownerId, $childrenCount, $invitationStatus, CalendarEvent::TENTATIVELY_ACCEPTED), 'view' => true, 'update' => $isEditable);
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:ActionPermissionProvider.php

示例14: onPreSetData

 /**
  * @param FormEvent $event
  * @return bool
  */
 public function onPreSetData(FormEvent $event)
 {
     /** @var $user AccountUser */
     $user = $this->securityFacade->getLoggedUser();
     if (!$user instanceof AccountUser) {
         return;
     }
     $account = $user->getAccount();
     /** @var AccountUser $data */
     $data = $event->getData();
     $data->setAccount($account);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:16,代码来源:FrontendAccountUserType.php

示例15: hasAccessEditField

 /**
  * @param User $entity
  *
  * {@inheritdoc}
  */
 public function hasAccessEditField($entity, $fieldName)
 {
     if (!$entity instanceof User) {
         $className = ClassUtils::getClass($entity);
         throw new IncorrectEntityException(sprintf('Entity %s, is not instance of User class', $className));
     }
     $currentUser = $this->securityFacade->getLoggedUser();
     if ($this->hasField($entity, $fieldName) && in_array($fieldName, $this->getCurrentUserFieldBlockList(), true) && $currentUser->getId() !== $entity->getId()) {
         return true;
     }
     return $this->hasField($entity, $fieldName) && !in_array($fieldName, $this->getCurrentUserFieldBlockList(), true);
 }
开发者ID:paulstoica,项目名称:platform,代码行数:17,代码来源:UserGridFieldValidator.php


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