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


PHP Hash::check方法代码示例

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


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

示例1: authorize

 /**
  * Check if the user is superuser
  *
  * @param type $user User information object.
  * @param Request $request Cake request object.
  * @return bool
  */
 public function authorize($user, Request $request)
 {
     $user = (array) $user;
     $superuserField = $this->config('superuser_field');
     if (Hash::check($user, $superuserField)) {
         return (bool) Hash::get($user, $superuserField);
     }
     return false;
 }
开发者ID:OrigamiStructures,项目名称:users,代码行数:16,代码来源:SuperuserAuthorize.php

示例2: authorize

 /**
  * Match the current plugin/controller/action against loaded permissions
  * Set a default role if no role is provided
  *
  * @param array $user user data
  * @param Request $request request
  * @return bool
  */
 public function authorize($user, Request $request)
 {
     $roleField = $this->config('role_field');
     $role = $this->config('default_role');
     if (Hash::check($user, $roleField)) {
         $role = Hash::get($user, $roleField);
     }
     $allowed = $this->_checkRules($user, $role, $request);
     return $allowed;
 }
开发者ID:OrigamiStructures,项目名称:users,代码行数:18,代码来源:SimpleRbacAuthorize.php

示例3: getEntity

 /**
  * @param string $entityName
  * @param array $data
  * @return Entity\EntityInterface
  * @throws Exception\LogicException
  */
 public function getEntity($entityName, array $data = [])
 {
     $class = '';
     $classCandidates = [__NAMESPACE__ . '\\Entity\\' . trim($entityName, '\\'), __NAMESPACE__ . '\\Entity\\Subset\\' . trim($entityName, '\\')];
     foreach ($classCandidates as $classCandidate) {
         if (class_exists($classCandidate)) {
             $class = $classCandidate;
             break;
         }
     }
     if (!$class) {
         throw new LogicException("Entity \"{$entityName}\" is undefined.");
     }
     $entity = new $class();
     if (!$entity instanceof EntityInterface) {
         throw new LogicException("Class \"{$class}\" isn't an implement of EntityInterface.");
     }
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             $childEntityName = Inflector::singularize((string) Inflector::camelize($key));
             if (Hash::check($value, '{s}')) {
                 // has string key => entity.
                 $value = $this->getEntity($childEntityName, $value);
             } elseif (Hash::check($value, '{n}.{s}')) {
                 // has string key under number key => array of entities.
                 $children = [];
                 foreach ($value as $child) {
                     $children[] = $this->getEntity($childEntityName, $child);
                 }
                 $value = $children;
             } else {
                 // else => array of scalar.
             }
         }
         if (property_exists($entity, $key)) {
             $entity->{$key} = $value;
         }
     }
     return $entity;
 }
开发者ID:quartetcom,项目名称:base-api-php-client,代码行数:46,代码来源:EntityManager.php

示例4: hasError

 /**
  * Check whether or not a field has an error attached to it
  *
  * @param string $field A dot separated path to check errors on.
  * @return bool Returns true if the errors for the field are not empty.
  */
 public function hasError($field)
 {
     if (empty($this->_context['errors'])) {
         return false;
     }
     return (bool) Hash::check($this->_context['errors'], $field);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:13,代码来源:ArrayContext.php

示例5: testCheck

 /**
  * testCheck method
  *
  * @return void
  */
 public function testCheck()
 {
     $set = ['My Index 1' => ['First' => 'The first item']];
     $this->assertTrue(Hash::check($set, 'My Index 1.First'));
     $this->assertTrue(Hash::check($set, 'My Index 1'));
     $set = ['My Index 1' => ['First' => ['Second' => ['Third' => ['Fourth' => 'Heavy. Nesting.']]]]];
     $this->assertTrue(Hash::check($set, 'My Index 1.First.Second'));
     $this->assertTrue(Hash::check($set, 'My Index 1.First.Second.Third'));
     $this->assertTrue(Hash::check($set, 'My Index 1.First.Second.Third.Fourth'));
     $this->assertFalse(Hash::check($set, 'My Index 1.First.Seconds.Third.Fourth'));
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:16,代码来源:HashTest.php

示例6: processCount

 public function processCount($oneEnd, $query)
 {
     $countTotalOnDay = [];
     foreach ($query as $key => $row) {
         $dateFormat = $row->date_result->i18nFormat('yyyy-MM-dd');
         if ($row->one_end == $oneEnd) {
             $countTotalOnDay[$dateFormat] = Hash::check($countTotalOnDay, $dateFormat) ? $countTotalOnDay[$dateFormat] + 1 : 1;
         }
     }
     $arrDurationPresent = [];
     $space = 0;
     foreach ($countTotalOnDay as $key => $value) {
         if ($value > 3) {
         } else {
             $space++;
             continue;
         }
         $arrDurationPresent[$space]['count'] = Hash::check($arrDurationPresent, "{$space}.count") ? $arrDurationPresent[$space]['count'] + 1 : 1;
         //$arrDurationPresent[$space]['date'][] = $key;
         $arrDurationPresent[$space]['index'] = $space;
         $space = 0;
     }
     $arrDurationPresent = Hash::sort($arrDurationPresent, '{n}.index', 'asc');
     return $arrDurationPresent;
 }
开发者ID:philliptan,项目名称:lode,代码行数:25,代码来源:PagesController.php

示例7: add

 /**
  * Add a menu item.
  *
  * @param $menu
  * @param $path
  * @param array $options
  */
 public static function add($menu, $path, $options = [])
 {
     // Juggle argument for backward compatibility
     if (is_array($path)) {
         $options = $path;
         $path = $menu;
         $menu = self::activeMenu();
     } else {
         self::activeMenu($menu);
     }
     $pathE = explode('.', $path);
     $pathE = array_splice($pathE, 0, count($pathE) - 2);
     $parent = join('.', $pathE);
     if (!empty($parent) && !Hash::check(self::$_items[$menu], $parent)) {
         $title = Inflector::humanize(end($pathE));
         $opt = ['title' => $title];
         self::_setupOptions($opt);
         self::add($parent, $opt);
     }
     self::_setupOptions($options);
     $current = Hash::extract(self::$_items[$menu], $path);
     if (!empty($current)) {
         self::_replace(self::$_items[$menu], $path, $options);
     } else {
         self::$_items[$menu] = Hash::insert(self::$_items[$menu], $path, $options);
     }
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:34,代码来源:Nav.php

示例8: hasJraOption

 /**
  * Checks if a particular option is available.
  *
  * @param string $path
  *
  * @return bool
  */
 public function hasJraOption($path)
 {
     return Hash::check($this->getJraOptions(), $path);
 }
开发者ID:bus-factor,项目名称:cakephp-json-rest-api,代码行数:11,代码来源:OptionsTrait.php


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