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


PHP ArrayUtils::findByKeyValue方法代码示例

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


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

示例1: getCachedInfo

 /**
  * Returns role info cached, or reads from db if not present.
  * Pass in a key to return a portion/index of the cached data.
  *
  * @param int         $id
  * @param null|string $key
  * @param null        $default
  *
  * @return mixed|null
  */
 public static function getCachedInfo($id, $key = null, $default = null)
 {
     $cacheKey = 'role:' . $id;
     try {
         $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use($id) {
             $role = Role::with(['role_lookup_by_role_id', 'role_service_access_by_role_id', 'service_by_role_service_access'])->whereId($id)->first();
             if (empty($role)) {
                 throw new NotFoundException("Role not found.");
             }
             $roleInfo = $role->toArray();
             $services = ArrayUtils::get($roleInfo, 'service_by_role_service_access');
             unset($roleInfo['service_by_role_service_access']);
             foreach ($roleInfo['role_service_access_by_role_id'] as $key => $value) {
                 $serviceName = ArrayUtils::findByKeyValue($services, 'id', ArrayUtils::get($value, 'service_id'), 'name');
                 $component = ArrayUtils::get($value, 'component');
                 $roleInfo['role_service_access_by_role_id'][$key]['service'] = $serviceName;
                 $roleInfo['role_service_access_by_role_id'][$key]['component'] = trim($component, '/');
             }
             return $roleInfo;
         });
         if (is_null($result)) {
             return $default;
         }
     } catch (ModelNotFoundException $ex) {
         return $default;
     }
     if (is_null($key)) {
         return $result;
     }
     return isset($result[$key]) ? $result[$key] : $default;
 }
开发者ID:pkdevboxy,项目名称:df-core,代码行数:41,代码来源:Role.php

示例2: getRole

 /** @inheritdoc */
 public function getRole()
 {
     if (ArrayUtils::get($this->config, 'map_group_to_role', false)) {
         $groups = $this->driver->getGroups();
         $primaryGroupDn = ArrayUtils::findByKeyValue($groups, 'primary', true, 'dn');
         $role = RoleADLdap::whereDn($primaryGroupDn)->first();
         if (empty($role)) {
             foreach ($groups as $group) {
                 $groupDn = ArrayUtils::get($group, 'dn');
                 $role = RoleADLdap::whereDn($groupDn)->first();
                 if (!empty($role)) {
                     return $role->role_id;
                 }
             }
             return $this->defaultRole;
         }
         return $role->role_id;
     }
     return $this->defaultRole;
 }
开发者ID:df-arif,项目名称:df-adldap,代码行数:21,代码来源:ADLdap.php

示例3: handleResource

 /**
  * @param array $resources
  *
  * @return bool|mixed
  * @throws BadRequestException
  * @throws InternalServerErrorException
  * @throws NotFoundException
  */
 protected function handleResource(array $resources)
 {
     $found = ArrayUtils::findByKeyValue($resources, 'name', $this->resource);
     if (isset($found, $found['class_name'])) {
         $className = $found['class_name'];
         if (!class_exists($className)) {
             throw new InternalServerErrorException('Service configuration class name lookup failed for resource ' . $this->resourcePath);
         }
         /** @var ResourceInterface $resource */
         $resource = $this->instantiateResource($className, $found);
         $newPath = $this->resourceArray;
         array_shift($newPath);
         $newPath = implode('/', $newPath);
         return $resource->handleRequest($this->request, $newPath);
     }
     throw new NotFoundException("Resource '{$this->resource}' not found for service '{$this->name}'.");
 }
开发者ID:df-arif,项目名称:df-core,代码行数:25,代码来源:RestHandler.php


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