當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TokenStorageInterface::isGranted方法代碼示例

本文整理匯總了PHP中Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::isGranted方法的典型用法代碼示例。如果您正苦於以下問題:PHP TokenStorageInterface::isGranted方法的具體用法?PHP TokenStorageInterface::isGranted怎麽用?PHP TokenStorageInterface::isGranted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface的用法示例。


在下文中一共展示了TokenStorageInterface::isGranted方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUserData

 /**
  * Get current user info.
  *
  * @return null|array
  */
 private function getUserData()
 {
     if (null === $this->tokenStorage) {
         return null;
     }
     if ($this->tokenStorage->getToken() && $this->tokenStorage->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $userData = array();
         $user = $this->tokenStorage->getToken()->getUser();
         if (!$user) {
             return null;
         }
         if (method_exists($user, 'getId')) {
             $userData['id'] = $user->getId();
         } else {
             // id is required
             $userData['id'] = $user->getUsername();
         }
         $userData['username'] = $user->getUsername();
         if (method_exists($user, 'getEmail')) {
             $userData['email'] = $user->getEmail();
         }
         return $userData;
     }
     return null;
 }
開發者ID:slayful,項目名稱:StaffimRollbarBundle,代碼行數:30,代碼來源:RollbarReporter.php

示例2: getResourceIfAllowed

 /**
  * Gets the resource if the current user is granted and if the resource exists.
  *
  * @param string $resourceId The resource id
  * @param string $grant      The grant, by default is view
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  *
  * @return Object
  */
 protected function getResourceIfAllowed($resourceId, $grant = 'view')
 {
     $resource = $this->repository->find($resourceId, false);
     if (!$this->context->isGranted($grant, $resource)) {
         throw new AccessDeniedException();
     }
     return $resource;
 }
開發者ID:dasklney,項目名稱:kreta,代碼行數:18,代碼來源:ResourceIfAllowedAnnotationListener.php

示例3: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     if ($this->authorizationChecker instanceof AuthorizationCheckerInterface) {
         if (!$this->tokenStorage->getToken()) {
             return;
         }
         if (!$this->authorizationChecker->isGranted($this->role)) {
             return;
         }
     } else {
         if (!$this->tokenStorage->getToken()) {
             return;
         }
         if (!$this->tokenStorage->isGranted($this->role)) {
             return;
         }
     }
     $resolver->setDefaults(array('csrf_protection' => false));
 }
開發者ID:RubenCox,項目名稱:Symfony_Web-Mobile,代碼行數:19,代碼來源:DisableCSRFExtension.php

示例4: isViewable

 /**
  * isViewable
  *
  * @param mixed $entity
  *
  * @return bool
  */
 public function isViewable($entity)
 {
     $editPermission = $entity instanceof Document ? 'DOCUMENT_EDIT' : 'NODE_EDIT';
     return $this->securityContext->isGranted('VIEW', $entity) && ($this->securityContext->isGranted($editPermission, $entity) || $entity->isEnabled());
 }
開發者ID:DavidG04,項目名稱:ErichardDmsBundle,代碼行數:12,代碼來源:DmsManager.php


注:本文中的Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::isGranted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。