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


PHP Storage\TokenStorageInterface类代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface的典型用法代码示例。如果您正苦于以下问题:PHP TokenStorageInterface类的具体用法?PHP TokenStorageInterface怎么用?PHP TokenStorageInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     /* @var $conn Connection */
     $conn = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $conn->expects($this->any())->method('getDatabase')->will($this->returnValue('myDatabase'));
     /* @var $platform AbstractPlatform */
     $platform = $this->getMockForAbstractClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
     $conn->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue($platform));
     /* @var $stmt Statement */
     $stmt = $this->getMockForAbstractClass('Kunstmaan\\AdminBundle\\Tests\\Mocks\\StatementMock');
     $conn->expects($this->any())->method('executeQuery')->will($this->returnValue($stmt));
     $this->em->expects($this->any())->method('getConnection')->will($this->returnValue($conn));
     /* @var $conf Configuration */
     $conf = $this->getMockBuilder('Doctrine\\ORM\\Configuration')->disableOriginalConstructor()->getMock();
     /* @var $strat QuoteStrategy */
     $strat = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\QuoteStrategy')->disableOriginalConstructor()->getMock();
     $strat->expects($this->any())->method('getTableName')->will($this->returnValue('rootTable'));
     $conf->expects($this->any())->method('getQuoteStrategy')->will($this->returnValue($strat));
     $conf->expects($this->any())->method('getDefaultQueryHints')->willReturn(array());
     $conf->expects($this->any())->method('isSecondLevelCacheEnabled')->willReturn(false);
     $this->em->expects($this->any())->method('getConfiguration')->will($this->returnValue($conf));
     /* @var $meta ClassMetadata */
     $meta = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($meta));
     $this->tokenStorage = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface')->getMock();
     $this->token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')->getMock();
     $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($this->token));
     $this->rh = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface')->getMock();
     $this->object = new AclHelper($this->em, $this->tokenStorage, $this->rh);
 }
开发者ID:BranchBit,项目名称:KunstmaanBundlesCMS,代码行数:35,代码来源:AclHelperTest.php

示例2:

 function it_returns_locale_of_currently_logged_admin_user(TokenStorageInterface $tokenStorage, TokenInterface $token, AdminUserInterface $admin)
 {
     $admin->getLocaleCode()->willReturn('en_US');
     $token->getUser()->willreturn($admin);
     $tokenStorage->getToken()->willReturn($token);
     $this->getLocaleCode()->shouldReturn('en_US');
 }
开发者ID:loic425,项目名称:Sylius,代码行数:7,代码来源:AdminBasedLocaleContextSpec.php

示例3: __construct

 /**
  * Set the username from injected security context
  * @param TokenStorageInterface $securityTokenStorage
  * @param AuditLogManager $auditLogManager
  */
 public function __construct(TokenStorageInterface $securityTokenStorage, AuditLogManager $auditLogManager)
 {
     if (null !== $securityTokenStorage && null !== $securityTokenStorage->getToken()) {
         $this->user = $securityTokenStorage->getToken()->getUser();
     }
     $this->manager = $auditLogManager;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:12,代码来源:Logger.php

示例4: __construct

 public function __construct(ItemFactory $navigationItemFactory, TokenStorageInterface $tokenStorage, EntityManager $entityManager, TitleServiceInterface $titleService)
 {
     $this->navItemFactory = $navigationItemFactory;
     $this->user = !$tokenStorage->getToken() || is_string($tokenStorage->getToken()->getUser()) ? null : $tokenStorage->getToken()->getUser();
     $this->em = $entityManager;
     $this->titleService = $titleService;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:ResponseHistoryListener.php

示例5: handle

 /**
  * {@inheritdoc}
  */
 public function handle(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (null !== ($authorization = $request->headers->get($this->authenticationHeaderName))) {
         $headerParts = array_map('trim', explode(' ', $authorization, 2));
         if (2 === count($headerParts)) {
             $credentialParts = explode(':', $headerParts[1]);
             if (2 === count($credentialParts)) {
                 $token = new HmacUserToken();
                 $token->setServiceLabel($headerParts[0]);
                 $token->setUser($credentialParts[0]);
                 $token->setSignature($credentialParts[1]);
                 $token->setRequest($request);
                 try {
                     $authenticatedToken = $this->authenticationManager->authenticate($token);
                     // Call setToken() on an instance of SecurityContextInterface or TokenStorageInterface (>=2.6)
                     $this->tokenStorage->setToken($authenticatedToken);
                     // Success
                     return;
                 } catch (AuthenticationException $exception) {
                 }
             }
         }
     }
     $event->setResponse(new Response(null, 401));
 }
开发者ID:wridgers,项目名称:GremoHmacAuthenticationBundle,代码行数:29,代码来源:HmacAuthenticationListener.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param TokenStorageInterface $aTokenStorage The token storage
  */
 public function __construct(TokenStorageInterface $aTokenStorage)
 {
     $token = $aTokenStorage->getToken();
     if ($token instanceof TokenInterface) {
         $this->currentUser = $token->getUser() instanceof UserInterface ? $token->getUser() : null;
     }
 }
开发者ID:BenGorUser,项目名称:UserBundle,代码行数:12,代码来源:RequestRememberPasswordType.php

示例7: __construct

 public function __construct(TokenStorageInterface $token, ComunidadProvider $comunidadProvider, ControllerResolverInterface $resolver, LoggerInterface $logger)
 {
     $this->token = $token->getToken();
     $this->comunidadProvider = $comunidadProvider;
     $this->resolver = $resolver;
     $this->logger = $logger;
 }
开发者ID:javiermadueno,项目名称:futbol,代码行数:7,代码来源:ComunidadListener.php

示例8: __construct

 /**
  * MenuHelper constructor.
  *
  * @param CorePermissions       $security
  * @param TokenStorageInterface $tokenStorage
  * @param RequestStack          $requestStack
  * @param array                 $mauticParameters
  */
 public function __construct(CorePermissions $security, TokenStorageInterface $tokenStorage, RequestStack $requestStack, array $mauticParameters)
 {
     $this->security = $security;
     $this->user = $tokenStorage->getToken()->getUser();
     $this->mauticParameters = $mauticParameters;
     $this->request = $requestStack->getCurrentRequest();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:15,代码来源:MenuHelper.php

示例9: __construct

 /**
  * AbstractJournalItemMailer constructor.
  * @param OjsMailer $ojsMailer
  * @param RegistryInterface $registry
  * @param TokenStorageInterface $tokenStorage
  * @param RouterInterface $router
  */
 public function __construct(OjsMailer $ojsMailer, RegistryInterface $registry, TokenStorageInterface $tokenStorage, RouterInterface $router)
 {
     $this->ojsMailer = $ojsMailer;
     $this->em = $registry->getManager();
     $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
     $this->router = $router;
 }
开发者ID:ojs,项目名称:ojs,代码行数:14,代码来源:AbstractJournalItemMailer.php

示例10: testBuild

 public function testBuild()
 {
     $type = 'history';
     $userId = 1;
     $user = $this->getMockBuilder('stdClass')->setMethods(['getId'])->getMock();
     $user->expects($this->once())->method('getId')->will($this->returnValue($userId));
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token));
     $item = $this->getMock('Oro\\Bundle\\NavigationBundle\\Entity\\NavigationItemInterface');
     $this->factory->expects($this->once())->method('createItem')->with($type, [])->will($this->returnValue($item));
     $repository = $this->getMockBuilder('Oro\\Bundle\\NavigationBundle\\Entity\\Repository\\HistoryItemRepository')->disableOriginalConstructor()->getMock();
     $items = [['id' => 1, 'title' => 'test1', 'url' => '/'], ['id' => 2, 'title' => 'test2', 'url' => '/home']];
     $repository->expects($this->once())->method('getNavigationItems')->with($userId, $type)->will($this->returnValue($items));
     $this->em->expects($this->once())->method('getRepository')->with(get_class($item))->will($this->returnValue($repository));
     $menu = $this->getMockBuilder('Knp\\Menu\\MenuItem')->disableOriginalConstructor()->getMock();
     $childMock = $this->getMock('Knp\\Menu\\ItemInterface');
     $childMock2 = clone $childMock;
     $children = [$childMock, $childMock2];
     $matcher = $this->getMock('\\Knp\\Menu\\Matcher\\Matcher');
     $matcher->expects($this->once())->method('isCurrent')->will($this->returnValue(true));
     $this->builder->setMatcher($matcher);
     $menu->expects($this->exactly(2))->method('addChild');
     $menu->expects($this->once())->method('setExtra')->with('type', $type);
     $menu->expects($this->once())->method('getChildren')->will($this->returnValue($children));
     $menu->expects($this->once())->method('removeChild');
     $n = rand(1, 10);
     $configMock = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\UserConfigManager')->disableOriginalConstructor()->getMock();
     $configMock->expects($this->once())->method('get')->with($this->equalTo('oro_navigation.maxItems'))->will($this->returnValue($n));
     $this->manipulator->expects($this->once())->method('slice')->with($menu, 0, $n);
     $this->builder->setOptions($configMock);
     $this->builder->build($menu, [], $type);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:33,代码来源:NavigationHistoryBuilderTest.php

示例11: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var \Claroline\CoreBundle\Entity\User $user */
     $user = $this->tokenStorage->getToken()->getUser();
     $locale = null === $user->getLocale() ? $this->platformConfigHandler->getParameter('locale_language') : $user->getLocale();
     $builder->add('badge', 'zenstruck_ajax_entity', array('attr' => array('class' => 'fullwidth'), 'theme_options' => array('control_width' => 'col-md-3'), 'placeholder' => $this->translator->trans('badge_form_badge_selection', array(), 'icap_badge'), 'class' => 'IcapBadgeBundle:Badge', 'use_controller' => true, 'repo_method' => sprintf('findByNameForAjax'), 'extra_data' => array('userId' => $user->getId(), 'locale' => $locale)));
 }
开发者ID:claroline,项目名称:distribution,代码行数:7,代码来源:ClaimBadgeType.php

示例12: indexAction

 /**
  * Get the attribute collection.
  *
  * TODO This action is only accessible via a GET or POST query, because of too long query URI. To respect standards,
  * a refactor must be done.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function indexAction(Request $request)
 {
     $options = [];
     $context = ['include_group' => true];
     if ($request->request->has('identifiers')) {
         $options['identifiers'] = explode(',', $request->request->get('identifiers'));
         $context['include_group'] = false;
     }
     if ($request->request->has('types')) {
         $options['types'] = explode(',', $request->request->get('types'));
     }
     if (empty($options)) {
         $options = $request->request->get('options', ['limit' => SearchableRepositoryInterface::FETCH_LIMIT, 'locale' => null]);
     }
     $token = $this->tokenStorage->getToken();
     $options['user_groups_ids'] = $token->getUser()->getGroupsIds();
     if (null !== $this->attributeSearchRepository) {
         $attributes = $this->attributeSearchRepository->findBySearch($request->request->get('search'), $options);
     } else {
         if (isset($options['identifiers'])) {
             $options['code'] = $options['identifiers'];
         }
         $attributes = $this->attributeRepository->findBy($options);
     }
     $normalizedAttributes = $this->normalizer->normalize($attributes, 'internal_api', $context);
     return new JsonResponse($normalizedAttributes);
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:37,代码来源:AttributeController.php

示例13: getUserFromTokenStorage

 private function getUserFromTokenStorage()
 {
     if (($token = $this->tokenStorage->getToken()) !== null) {
         return $token->getUser();
     }
     throw new \RuntimeException('I don\'t have a token');
 }
开发者ID:WeCamp,项目名称:ihaveanidea,代码行数:7,代码来源:Idea.php

示例14: getUser

 /**
  * @return \Symfony\Component\Security\Core\User\UserInterface
  */
 private function getUser()
 {
     if (is_null($this->user)) {
         $this->user = $this->tokenStorage->getToken()->getUser();
     }
     return $this->user;
 }
开发者ID:BranchBit,项目名称:KunstmaanBundlesCMS,代码行数:10,代码来源:LogPageEventsSubscriber.php

示例15: merge

 /**
  * Merge in dashboard list into runtime configuration.
  *
  * {@inheritdoc}
  */
 public function merge(array $currentConfig)
 {
     /** @var User $user */
     $user = $this->tokenStorage->getToken()->getUser();
     $defaultDashboardNames = [];
     foreach ($this->dashboardMgr->getDefaultDashboards($user) as $dashboard) {
         $defaultDashboardNames[] = $dashboard->getName();
     }
     $isDefaultFound = false;
     $result = array();
     foreach ($this->dashboardMgr->getUserDashboards($user) as $dashboard) {
         if (!$dashboard->isAllowed($this->container)) {
             continue;
         }
         $isDefault = in_array($dashboard->getName(), $defaultDashboardNames);
         if ($isDefault) {
             $isDefaultFound = true;
         }
         $result[] = array_merge($this->serializeDashboard($dashboard), array('default' => $isDefault));
     }
     if (!$isDefaultFound) {
         // if there's no default dashboard available for a given user then we will display a dashboard
         // where user will be able to pick one he/she needs
         $dashboard = new SimpleDashboard('default', 'List of user dashboards', 'Modera.backend.dashboard.runtime.DashboardListDashboardActivity');
         $result[] = array_merge($this->serializeDashboard($dashboard), array('default' => true));
     }
     return array_merge($currentConfig, array('modera_backend_dashboard' => array('dashboards' => $result)));
 }
开发者ID:modera,项目名称:foundation,代码行数:33,代码来源:ConfigMergersProvider.php


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