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


PHP Hash::dimensions方法代码示例

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


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

示例1: testDimensions

 /**
  * Test dimensions.
  *
  * @return void
  */
 public function testDimensions()
 {
     $result = Hash::dimensions(array());
     $this->assertEquals($result, 0);
     $data = array('one', '2', 'three');
     $result = Hash::dimensions($data);
     $this->assertEquals($result, 1);
     $data = array('1' => '1.1', '2', '3');
     $result = Hash::dimensions($data);
     $this->assertEquals($result, 1);
     $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => '3.1.1'));
     $result = Hash::dimensions($data);
     $this->assertEquals($result, 2);
     $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1'));
     $result = Hash::dimensions($data);
     $this->assertEquals($result, 1);
     $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
     $result = Hash::dimensions($data);
     $this->assertEquals($result, 2);
 }
开发者ID:abhinand4858,项目名称:ProgrammedV,代码行数:25,代码来源:HashTest.php

示例2: __processFiles

 /**
  * Process $_FILES
  * 
  * @author	Anthony Putignano <anthony@wizehive.com>
  * @since	1.0
  * @return	void 
  */
 protected function __processFiles()
 {
     if (!empty($_FILES)) {
         $dimensions = Hash::dimensions($_FILES);
         if ($dimensions === 2) {
             $this->Controller->request->data = Hash::merge($this->Controller->request->data, $_FILES);
         } else {
             foreach ($_FILES as $key => $data) {
                 $parsed = array();
                 foreach (array('name', 'type', 'tmp_name', 'error') as $file_key) {
                     $flattened = Hash::flatten($_FILES[$key][$file_key]);
                     foreach ($flattened as $flat_key => $flat_value) {
                         $reflattened = $key . '.' . $flat_key . '.' . $file_key;
                         $parsed[$reflattened] = $flat_value;
                     }
                 }
                 $parsed = Hash::expand($parsed);
                 $this->Controller->request->data = Hash::merge($this->Controller->request->data, $parsed);
             }
         }
     }
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:29,代码来源:ApiRequestHandlerComponent.php

示例3: _addToWhiteList

 /**
  * Helper method for saveAll() and friends, to add foreign key to fieldlist
  *
  * @param string $key fieldname to be added to list
  * @param array $options
  * @return array $options
  */
 protected function _addToWhiteList($key, $options)
 {
     if (empty($options['fieldList']) && $this->whitelist && !in_array($key, $this->whitelist)) {
         $options['fieldList'][$this->alias] = $this->whitelist;
         $options['fieldList'][$this->alias][] = $key;
         return $options;
     }
     if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) {
         $options['fieldList'][$this->alias][] = $key;
         return $options;
     }
     if (!empty($options['fieldList']) && is_array($options['fieldList']) && Hash::dimensions($options['fieldList']) < 2) {
         $options['fieldList'][] = $key;
     }
     return $options;
 }
开发者ID:ajayphp,项目名称:Zuha,代码行数:23,代码来源:Model.php

示例4: _processValidationRules

 /**
  * Process a validation rule for a field and looks for a message to be added
  * to the translation map
  *
  * @param string $field the name of the field that is being processed
  * @param array $rules the set of validation rules for the field
  * @param string $file the file name where this validation rule was found
  * @param string $domain default domain to bind the validations to
  * @param string $category the translation category
  * @return void
  */
 protected function _processValidationRules($field, $rules, $file, $domain, $category = 'LC_MESSAGES')
 {
     if (!is_array($rules)) {
         return;
     }
     $dims = Hash::dimensions($rules);
     if ($dims === 1 || $dims === 2 && isset($rules['message'])) {
         $rules = array($rules);
     }
     foreach ($rules as $rule => $validateProp) {
         $msgid = null;
         if (isset($validateProp['message'])) {
             if (is_array($validateProp['message'])) {
                 $msgid = $validateProp['message'][0];
             } else {
                 $msgid = $validateProp['message'];
             }
         } elseif (is_string($rule)) {
             $msgid = $rule;
         }
         if ($msgid) {
             $msgid = $this->_formatString(sprintf("'%s'", $msgid));
             $details = array('file' => $file, 'line' => 'validation for field ' . $field);
             $this->_addTranslation($category, $domain, $msgid, $details);
         }
     }
 }
开发者ID:Vighnesh123,项目名称:book-a-bus,代码行数:38,代码来源:ExtractTask.php

示例5: _validationList

 /**
  * Processes the passed fieldList and returns the list of fields to be validated
  *
  * @param array $fieldList list of fields to be used for validation
  * @return array List of validation rules to be applied
  */
 protected function _validationList($fieldList = array())
 {
     if (empty($fieldList) || Hash::dimensions($fieldList) > 1) {
         return $this->_fields;
     }
     $validateList = array();
     $this->validationErrors = array();
     foreach ((array) $fieldList as $f) {
         if (!empty($this->_fields[$f])) {
             $validateList[$f] = $this->_fields[$f];
         }
     }
     return $validateList;
 }
开发者ID:clanclan,项目名称:rest-study,代码行数:20,代码来源:ModelValidator.php

示例6: _validationList

 /**
  * Processes the Model's whitelist or passed fieldList and returns the list of fields
  * to be validated
  *
  * @param array $fieldList list of fields to be used for validation
  * @return array List of validation rules to be applied
  */
 protected function _validationList($fieldList = array())
 {
     $model = $this->getModel();
     $whitelist = $model->whitelist;
     if (!empty($fieldList)) {
         if (!empty($fieldList[$model->alias]) && is_array($fieldList[$model->alias])) {
             $whitelist = $fieldList[$model->alias];
         } else {
             $whitelist = $fieldList;
         }
     }
     unset($fieldList);
     if (empty($whitelist) || Hash::dimensions($whitelist) > 1) {
         return $this->_fields;
     }
     $validateList = array();
     $this->validationErrors = array();
     foreach ((array) $whitelist as $f) {
         if (!empty($this->_fields[$f])) {
             $validateList[$f] = $this->_fields[$f];
         }
     }
     return $validateList;
 }
开发者ID:ejcumbane,项目名称:ExameNdaw2015,代码行数:31,代码来源:ModelValidator.php

示例7: afterFind

 /**
  * AfterFind
  **/
 public function afterFind(Model $model, $results = array(), $primary = false)
 {
     parent::afterFind($model, $results, $primary);
     if ($model->findQueryType == 'count') {
         return $results;
     }
     $curObj = $model->alias;
     foreach ($results as $key => $value) {
         $tmpkeys = array_keys($value);
         foreach ($tmpkeys as $curmodel) {
             $curObj = $curmodel != $model->alias ? $model->{$curmodel} : $model;
             $columnTypes = $curObj->getColumnTypes();
             $fields = array_filter($columnTypes, array($this, 'valueIsDate'));
             /**
              * @todo Array walk might be a solution for deeper associations?
              **/
             foreach ($fields as $field => $fieldvalue) {
                 $curvalues = $results[$key][$curmodel];
                 $dimensions = Hash::dimensions($curvalues);
                 if ($dimensions <= 1) {
                     if (!array_key_exists($field, $results[$key][$curmodel])) {
                         continue;
                     }
                     $results[$key][$curmodel][$field] = $this->formatDate($results[$key][$curmodel][$field]);
                     continue;
                 }
             }
         }
     }
     return $results;
 }
开发者ID:raponiwalter,项目名称:Autodate,代码行数:34,代码来源:AutodateBehavior.php


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