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


PHP SecurityFacade::hasLoggedUser方法代码示例

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


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

示例1: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     $menu = $event->getMenu();
     $children = array();
     $entitiesMenuItem = $menu->getChild('system_tab')->getChild('entities_list');
     if ($entitiesMenuItem) {
         /** @var ConfigProvider $entityConfigProvider */
         $entityConfigProvider = $this->configManager->getProvider('entity');
         /** @var ConfigProvider $entityExtendProvider */
         $entityExtendProvider = $this->configManager->getProvider('extend');
         $extendConfigs = $entityExtendProvider->getConfigs();
         foreach ($extendConfigs as $extendConfig) {
             if ($this->checkAvailability($extendConfig)) {
                 $config = $entityConfigProvider->getConfig($extendConfig->getId()->getClassname());
                 if (!class_exists($config->getId()->getClassName()) || !$this->securityFacade->hasLoggedUser() || !$this->securityFacade->isGranted('VIEW', 'entity:' . $config->getId()->getClassName())) {
                     continue;
                 }
                 $children[$config->get('label')] = array('label' => $this->translator->trans($config->get('label')), 'options' => array('route' => 'oro_entity_index', 'routeParameters' => array('entityName' => str_replace('\\', '_', $config->getId()->getClassName())), 'extras' => array('safe_label' => true, 'routes' => array('oro_entity_*'))));
             }
         }
         sort($children);
         foreach ($children as $child) {
             $entitiesMenuItem->addChild($child['label'], $child['options']);
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:29,代码来源:NavigationListener.php

示例2: processAcl

 /**
  * Check ACL based on acl_resource_id, route or uri.
  *
  * @param array $options
  */
 protected function processAcl(array &$options = array())
 {
     $needCheck = (!isset($options['check_access']) || $options['check_access'] === true) && $this->securityFacade->hasLoggedUser();
     $isAllowed = self::DEFAULT_ACL_POLICY;
     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 {
             if ($needCheck) {
                 $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 {
                 if ($needCheck) {
                     $isAllowed = $this->securityFacade->isClassMethodGranted($routeInfo['controller'], $routeInfo['action']);
                 }
                 $this->aclCache[$routeInfo['key']] = $isAllowed;
             }
         }
     }
     $options['extras']['isAllowed'] = $isAllowed;
 }
开发者ID:xamin123,项目名称:platform,代码行数:33,代码来源:AclAwareMenuFactoryExtension.php

示例3: isAllowed

 /**
  * {@inheritdoc}
  */
 public function isAllowed()
 {
     if (!$this->acl) {
         return true;
     }
     return $this->securityFacade->hasLoggedUser() && $this->securityFacade->isGranted($this->acl);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:DataStorageAwareProcessor.php

示例4: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     /** @var ItemInterface $reportsMenuItem */
     $reportsMenuItem = $event->getMenu()->getChild('reports_tab');
     if ($reportsMenuItem && $this->securityFacade->hasLoggedUser()) {
         $qb = $this->em->getRepository('OroReportBundle:Report')->createQueryBuilder('report')->orderBy('report.name', 'ASC');
         $reports = $this->aclHelper->apply($qb)->execute();
         if (!empty($reports)) {
             $this->addDivider($reportsMenuItem);
             $reportMenuData = [];
             foreach ($reports as $report) {
                 $config = $this->entityConfigProvider->getConfig($report->getEntity());
                 if ($this->checkAvailability($config)) {
                     $entityLabel = $config->get('plural_label');
                     if (!isset($reportMenuData[$entityLabel])) {
                         $reportMenuData[$entityLabel] = [];
                     }
                     $reportMenuData[$entityLabel][$report->getId()] = $report->getName();
                 }
             }
             ksort($reportMenuData);
             $this->buildReportMenu($reportsMenuItem, $reportMenuData);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:NavigationListener.php

示例5: isAllowed

 /**
  * @param ShoppingList|null $shoppingList
  * @return bool
  */
 public function isAllowed(ShoppingList $shoppingList = null)
 {
     if (!$this->securityFacade->hasLoggedUser()) {
         return false;
     }
     $isAllowed = $this->securityFacade->isGranted('orob2b_shopping_list_line_item_frontend_add');
     if (!$shoppingList) {
         return $isAllowed;
     }
     return $isAllowed && $this->securityFacade->isGranted('EDIT', $shoppingList);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:15,代码来源:ShoppingListLineItemHandler.php

示例6: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     $dashboardTab = $event->getMenu()->getChild('dashboard_tab');
     if (!$dashboardTab || !$this->securityFacade->hasLoggedUser()) {
         return;
     }
     $dashboards = $this->manager->findAllowedDashboards();
     if (count($dashboards) > 0) {
         foreach ($dashboards as $dashboard) {
             $dashboardId = $dashboard->getId();
             $dashboardLabel = $dashboard->getLabel();
             $dashboardLabel = strlen($dashboardLabel) > 50 ? substr($dashboardLabel, 0, 50) . '...' : $dashboardLabel;
             $options = array('label' => $dashboardLabel, 'route' => 'oro_dashboard_view', 'extras' => array('position' => 1), 'routeParameters' => array('id' => $dashboardId, 'change_dashboard' => true));
             $dashboardTab->addChild($dashboardId . '_dashboard_menu_item', $options)->setAttribute('data-menu', $dashboardId);
         }
         $dashboardTab->addChild('divider-' . rand(1, 99999))->setLabel('')->setAttribute('class', 'divider menu-divider')->setExtra('position', 2);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:21,代码来源:NavigationListener.php

示例7: getUnreadEmailsCount

 /**
  * Return array of numbers unread emails per folder
  *
  * @return array
  */
 public function getUnreadEmailsCount()
 {
     if (!$this->securityFacade->hasLoggedUser()) {
         return [];
     }
     $currentOrganization = $this->securityFacade->getOrganization();
     $currentUser = $this->securityFacade->getLoggedUser();
     $result = $this->em->getRepository("OroEmailBundle:Email")->getCountNewEmailsPerFolders($currentUser, $currentOrganization);
     $total = $this->em->getRepository("OroEmailBundle:Email")->getCountNewEmails($currentUser, $currentOrganization);
     $result[] = array('num' => $total, 'id' => 0);
     return $result;
 }
开发者ID:antrampa,项目名称:platform,代码行数:17,代码来源:EmailExtension.php

示例8: 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


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