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


PHP SecurityFacade::getToken方法代码示例

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


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

示例1: process

 /**
  * Process form
  *
  * @param AccountUser $accountUser
  * @return bool True on successful processing, false otherwise
  */
 public function process(AccountUser $accountUser)
 {
     if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             if (!$accountUser->getId()) {
                 if ($this->form->get('passwordGenerate')->getData()) {
                     $generatedPassword = $this->userManager->generatePassword(10);
                     $accountUser->setPlainPassword($generatedPassword);
                 }
                 if ($this->form->get('sendEmail')->getData()) {
                     $this->userManager->sendWelcomeEmail($accountUser);
                 }
             }
             $token = $this->securityFacade->getToken();
             if ($token instanceof OrganizationContextTokenInterface) {
                 $organization = $token->getOrganizationContext();
                 $accountUser->setOrganization($organization)->addOrganization($organization);
             }
             $this->userManager->updateUser($accountUser);
             return true;
         }
     }
     return false;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:31,代码来源:AccountUserHandler.php

示例2: linkToScope

 /**
  * @param EmailBodyAdded $event
  */
 public function linkToScope(EmailBodyAdded $event)
 {
     if ($this->securityFacade->getToken() !== null && !$this->securityFacade->isGranted('CREATE', 'entity:' . AttachmentScope::ATTACHMENT)) {
         return;
     }
     $email = $event->getEmail();
     $entities = $this->activityListProvider->getTargetEntities($email);
     foreach ($entities as $entity) {
         if ((bool) $this->configProvider->getConfig(ClassUtils::getClass($entity))->get('auto_link_attachments')) {
             foreach ($email->getEmailBody()->getAttachments() as $attachment) {
                 $this->attachmentManager->linkEmailAttachmentToTargetEntity($attachment, $entity);
             }
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:18,代码来源:EmailBodyAddListener.php

示例3: getCurrentEmailUser

 /**
  * Find EmilUser User logged in system
  *
  * @param Email $entity - entity Email
  *
  * @return null|EmailUser
  */
 protected function getCurrentEmailUser(Email $entity)
 {
     $user = $this->securityFacade->getToken()->getUser();
     $currentOrganization = $this->securityFacade->getOrganization();
     $emailUser = $this->em->getRepository('OroEmailBundle:EmailUser')->findByEmailAndOwner($entity, $user, $currentOrganization);
     return $emailUser;
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:EmailManager.php

示例4: processAcl

 /**
  * Check ACL based on acl_resource_id, route or uri.
  *
  * @param array $options
  *
  * @return void
  */
 protected function processAcl(array &$options = array())
 {
     $isAllowed = self::DEFAULT_ACL_POLICY;
     $options['extras']['isAllowed'] = self::DEFAULT_ACL_POLICY;
     if (isset($options['check_access']) && $options['check_access'] === false) {
         return;
     }
     if ($this->hideAllForNotLoggedInUsers && !$this->securityFacade->hasLoggedUser()) {
         if (isset($options['extras']) && array_key_exists('showNonAuthorized', $options['extras']) && $options['extras']['showNonAuthorized']) {
             return;
         }
         $isAllowed = false;
     } elseif ($this->securityFacade->getToken() !== null) {
         // don't check access if it's CLI
         if (array_key_exists('extras', $options) && array_key_exists(self::ACL_POLICY_KEY, $options['extras'])) {
             $isAllowed = $options['extras'][self::ACL_POLICY_KEY];
         }
         if (array_key_exists(self::ACL_RESOURCE_ID_KEY, $options)) {
             if (array_key_exists($options[self::ACL_RESOURCE_ID_KEY], $this->aclCache)) {
                 $isAllowed = $this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]];
             } else {
                 $isAllowed = $this->securityFacade->isGranted($options[self::ACL_RESOURCE_ID_KEY]);
                 $this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]] = $isAllowed;
             }
         } else {
             $routeInfo = $this->getRouteInfo($options);
             if ($routeInfo) {
                 if (array_key_exists($routeInfo['key'], $this->aclCache)) {
                     $isAllowed = $this->aclCache[$routeInfo['key']];
                 } else {
                     $isAllowed = $this->securityFacade->isClassMethodGranted($routeInfo['controller'], $routeInfo['action']);
                     $this->aclCache[$routeInfo['key']] = $isAllowed;
                 }
             }
         }
     }
     $options['extras']['isAllowed'] = $isAllowed;
 }
开发者ID:snorchel,项目名称:platform,代码行数:45,代码来源:AclAwareMenuFactoryExtension.php

示例5: getCurrentEmailUser

 /**
  * Find EmilUser User logged in system
  *
  * @param Email $entity - entity Email
  *
  * @return EmailUser[]
  */
 protected function getCurrentEmailUser(Email $entity)
 {
     $user = $this->securityFacade->getToken()->getUser();
     $currentOrganization = $this->securityFacade->getOrganization();
     return array_merge($this->getEmailUserRepository()->findByEmailAndOwner($entity, $user, $currentOrganization), $this->getEmailUserRepository()->findByEmailForMailbox($entity));
 }
开发者ID:antrampa,项目名称:platform,代码行数:13,代码来源:EmailManager.php

示例6: isApplicable

 /**
  * {@inheritdoc}
  */
 public function isApplicable(DatagridConfiguration $config)
 {
     $className = $this->getEntityClassName($config);
     return !$this->isReportOrSegmentGrid($config) && $className && $this->taggableHelper->isTaggable($className) && null !== $config->offsetGetByPath(self::PROPERTY_ID_PATH) && null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view');
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:TagsExtension.php

示例7: getUser

 /**
  * @return User
  */
 protected function getUser()
 {
     return $this->securityFacade->getToken()->getUser();
 }
开发者ID:ramunasd,项目名称:platform,代码行数:7,代码来源:ChoiceTreeBusinessUnitProvider.php

示例8: isAccessGranted

 /**
  * @return bool
  */
 protected function isAccessGranted()
 {
     return null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view');
 }
开发者ID:ramunasd,项目名称:platform,代码行数:7,代码来源:TagsExtension.php


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