當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。