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


PHP Hash::normalize方法代码示例

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


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

示例1: setup

 /**
  * Setup
  *
  * Sets up the configuration for the model
  *
  * @author  Paul Smith <paul@wizehive.com>
  * @since   1.0
  * @param   Model $model
  * @param   array $config
  * @return  void
  */
 public function setup(Model $Model, $settings = array())
 {
     foreach (array('json', 'serialized') as $type) {
         if (isset($settings[$type])) {
             // Automatically parse json & serialized field structure from model attributes
             $settings[$type] = Hash::normalize($settings[$type]);
             foreach ($settings[$type] as $field => $attribute) {
                 if (empty($attribute)) {
                     $settings[$type][$field] = $attribute = $field;
                 }
             }
             $modelAttributes = Hash::expand($Model->attributes());
             foreach ($settings[$type] as $field => $attribute) {
                 $match = Hash::extract($modelAttributes, $attribute);
                 if (!empty($match)) {
                     $this->settings[$Model->alias][$type][$field] = $match;
                 }
             }
         } else {
             $this->settings[$Model->alias][$type] = array();
         }
     }
     $this->settings[$Model->alias]['virtual'] = isset($settings['virtual']) ? $settings['virtual'] : false;
     $this->settings[$Model->alias]['callback'] = isset($settings['callback']) ? $settings['callback'] : false;
     // Set up callback fields for this model
     if ($this->settings[$Model->alias]['callback']) {
         $this->__setupSpecialFields($Model, 'callback');
     }
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:40,代码来源:SpecialFieldsBehavior.php

示例2: setup

 /**
  * {@inheritdoc}
  */
 public function setup(Model $Model, $config = array())
 {
     if (empty($config)) {
         $config = $this->_defaults;
     }
     $this->settings[$Model->alias] = Hash::normalize((array) $config);
 }
开发者ID:gourmet,项目名称:common,代码行数:10,代码来源:FilterableBehavior.php

示例3: testInstanceSetup

 /**
  * Test Instance Setup
  *
  * @author  Everton Yoshitani <everton@wizehive.com>
  * @since   1.0
  * @return  void
  */
 public function testInstanceSetup()
 {
     $components = Hash::normalize($this->Permissions->components);
     $this->assertArrayHasKey('Auth', $components);
     $this->assertInstanceOf('AuthComponent', $this->Permissions->Auth);
     $this->assertArrayHasKey('Acl', $components);
     $this->assertInstanceOf('AclComponent', $this->Permissions->Acl);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:15,代码来源:ApiPermissionsComponentTest.php

示例4: setup

 /**
  * {@inheritdoc}
  */
 public function setup(Model $Model, $config = array())
 {
     if (!empty($config) && (!array_key_exists('fields', (array) $config) && Hash::numeric((array) array_keys($config)))) {
         $config = array('fields' => Hash::normalize($config));
     }
     $this->settings[$Model->alias] = array_merge($this->_defaults, $config);
     $this->bindSecurityToken($Model);
 }
开发者ID:gourmet,项目名称:security,代码行数:11,代码来源:TokenizableBehavior.php

示例5: testInstanceSetup

 /**
  * Test Instance Setup
  *
  * @author  Everton Yoshitani <everton@wizehive.com>
  * @since   1.0
  * @return  void
  */
 public function testInstanceSetup()
 {
     // Test Components
     $components = Hash::normalize($this->Api->components);
     $this->assertArrayHasKey('Query', $components);
     $this->assertArrayHasKey('InputData', $components);
     $this->assertArrayHasKey('Permissions', $components);
     $this->assertArrayHasKey('Resource', $components);
     $this->assertArrayHasKey('ApiPaginator', $components);
     $this->assertArrayHasKey('ApiRequestHandler', $components);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:18,代码来源:ApiComponentTest.php

示例6: constructLimits

 public function constructLimits()
 {
     $global = array('callback' => array('flash', array('security.access_limit.fail')), 'duration' => '+1 hour', 'limit' => 5);
     if (!empty($this->settings[AccessLimitComponent::ALL])) {
         $global = array_merge($global, $this->settings[AccessLimitComponent::ALL]);
         unset($this->settings[AccessLimitComponent::ALL]);
     }
     foreach ($this->settings as $requestType => $settings) {
         $this->{$requestType} = array();
         foreach (Hash::normalize($settings) as $action => $limit) {
             if (!empty($limit) && !is_array($limit)) {
                 $limit = compact('limit');
             }
             $this->{$requestType}[$action] = array_merge($global, (array) $limit);
         }
     }
 }
开发者ID:gourmet,项目名称:security,代码行数:17,代码来源:AccessLimitComponent.php

示例7: __construct

 /**
  * Overrides `Model::__construct()`.
  *
  * - Auto-load plugin behaviors using the 'Model.construct' event.
  *
  * @param integer|string|array $id Set this ID for this model on startup, can also be an array of options, see above.
  * @param string $table Name of database table to use.
  * @param string $ds DataSource connection name.
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     foreach (get_class_methods($this) as $method) {
         $key = lcfirst(str_replace('_find', '', $method));
         if (isset($this->findMethods[$key]) || strpos($method, '_find') !== 0) {
             continue;
         }
         $ReflectionMethod = new ReflectionMethod($this, $method);
         $params = $ReflectionMethod->getParameters();
         foreach (array('state', 'query', 'results') as $k => $name) {
             if ((array) $params[$k] != compact('name')) {
                 $key = null;
                 break;
             }
         }
         if (!empty($key)) {
             $this->findMethods[$key] = true;
         }
     }
     if (empty($this->friendly)) {
         $this->friendly = Inflector::humanize(Inflector::underscore($this->name));
     }
     $timer = 'modelConstruct' . $this->alias;
     Common::startTimer($timer, __d('common', "Event: Model.construct (%s)", $this->alias));
     $result = array_merge(array('actsAs' => array()), (array) $this->triggerEvent('Model.construct', $this));
     $this->actsAs = Hash::merge(Hash::normalize((array) $result['actsAs']), Hash::normalize((array) $this->actsAs));
     unset($result['actsAs']);
     foreach ($this->actsAs as $name => $config) {
         list(, $behavior) = pluginSplit($name);
         if (!$this->Behaviors->loaded($behavior)) {
             $this->Behaviors->load($name, $config);
         }
     }
     $this->_set($result);
     Common::stopTimer($timer);
 }
开发者ID:gourmet,项目名称:common,代码行数:46,代码来源:CommonAppModel.php

示例8: _mergePropertyData

 /**
  * Merge each of the keys in a property together.
  *
  * @param array $current The current merged value.
  * @param array $parent The parent class' value.
  * @param bool $isAssoc Whether or not the merging should be done in associative mode.
  * @return mixed The updated value.
  */
 protected function _mergePropertyData($current, $parent, $isAssoc)
 {
     if (!$isAssoc) {
         return array_merge($parent, $current);
     }
     $parent = Hash::normalize($parent);
     foreach ($parent as $key => $value) {
         if (!isset($current[$key])) {
             $current[$key] = $value;
         }
     }
     return $current;
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:21,代码来源:MergeVariablesTrait.php

示例9: getOptionParser

 /**
  * {@inheritdoc}
  * 
  * @return ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $parser->description('There is no help');
     $taskNames = array_keys(Hash::normalize($this->tasks));
     foreach ($taskNames as $taskName) {
         $Task = $this->{$taskName};
         $parser->addSubcommand(Inflector::underscore($Task->name), array('help' => $Task->getOptionParser()->description(), 'parser' => $Task->getOptionParser()));
     }
     return $parser;
 }
开发者ID:imsamurai,项目名称:cakephp-advancedshell,代码行数:16,代码来源:AdvancedShell.php

示例10: constructClasses

 /**
  * Overrides `Controller::constructClasses()` to apply the 'Controller.constructClasses'
  * event's results.
  *
  * @return  void
  */
 public function constructClasses()
 {
     $timer = 'controllerConstructClasses';
     Common::startTimer($timer, __d('common', "Event: Controller.constructClasses"));
     $properties = array('components', 'helpers');
     $result = $this->triggerEvent('Controller.constructClasses', $this);
     $this->_mergeControllerVars();
     foreach ($properties as $property) {
         if (!isset($result[$property])) {
             continue;
         }
         $this->{$property} = Hash::merge(Hash::normalize($result[$property]), Hash::normalize((array) $this->{$property}));
         unset($result[$property]);
     }
     $this->_set($result);
     Common::stopTimer($timer);
     parent::constructClasses();
 }
开发者ID:gourmet,项目名称:common,代码行数:24,代码来源:CommonAppController.php

示例11: _normalizeConfig

 /**
  * Normalize action configuration
  *
  * If an action doesn't have a CrudClass specified (the value part of the array)
  * try to compute it by exploding on action name on '_' and take the last chunk
  * as CrudClass identifier.
  *
  * @param mixed $types Class type(s).
  * @return void
  * @throws CakeException If className is missing for listener.
  */
 protected function _normalizeConfig($types = null)
 {
     if (!$types) {
         $types = array('listeners', 'actions');
     }
     foreach ((array) $types as $type) {
         $this->settings[$type] = Hash::normalize($this->settings[$type]);
         foreach ($this->settings[$type] as $name => $settings) {
             if (is_array($settings) && !empty($settings['className'])) {
                 $this->settings[$type][$name] = $settings;
                 continue;
             }
             $className = null;
             if (empty($settings)) {
                 $settings = array();
             } elseif (is_string($settings)) {
                 $className = $settings;
                 $settings = array();
             }
             if ($type === 'listeners' && strpos($name, '.') !== false) {
                 unset($this->settings[$type][$name]);
                 $settings['className'] = $name;
                 list($plugin, $name) = pluginSplit($name);
                 $name = Inflector::camelize($name);
             }
             $className = $this->_handlerClassName($name, $className);
             if (empty($settings['className'])) {
                 $settings['className'] = $className;
             }
             $this->settings[$type][$name] = $settings;
         }
     }
 }
开发者ID:sebbdk,项目名称:booking,代码行数:44,代码来源:CrudComponent.php

示例12: unbindModel

 /**
  * Turn off associations on the fly.
  *
  * If $reset is false, association will not be reset
  * to the originals defined in the model
  *
  * Example: Turn off the associated Model Support request,
  * to temporarily lighten the User model:
  *
  * `$this->User->unbindModel(array('hasMany' => array('SupportRequest')));`
  * Or alternatively:
  * `$this->User->unbindModel(array('hasMany' => 'SupportRequest'));`
  *
  * Unbound models that are not made permanent will reset with the next call to Model::find()
  *
  * @param array $params Set of bindings to unbind (indexed by binding type)
  * @param bool  $reset  Set to false to make the unbinding permanent
  *
  * @return bool Success
  * @link http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#creating-and-destroying-associations-on-the-fly
  */
 public function unbindModel($params, $reset = TRUE)
 {
     foreach ($params as $assoc => $models) {
         if ($reset === TRUE && !isset($this->__backAssociation[$assoc])) {
             $this->__backAssociation[$assoc] = $this->{$assoc};
         }
         $models = Hash::normalize((array) $models, FALSE);
         foreach ($models as $model) {
             if ($reset === FALSE && isset($this->__backAssociation[$assoc][$model])) {
                 unset($this->__backAssociation[$assoc][$model]);
             }
             unset($this->{$assoc}[$model]);
         }
     }
     return TRUE;
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:37,代码来源:Model.php

示例13: testAttributes

 /**
  * Test Attributes
  *
  * @author  Everton Yoshitani <everton@wizehive.com>
  * @since	1.0
  * @return  void
  */
 public function testAttributes()
 {
     $this->TestModel->expects($this->exactly(2))->method('schema')->with()->will($this->returnValue(array('some_field' => array('type' => 'integer'), 'some_other_field' => array('type' => 'string'), 'created' => array('type' => 'datetime'))));
     $attributes = $this->TestModel->_attributes;
     $attributes['someAttribute'] = array('field' => 'some_field');
     $attributes['someOtherAttribute'] = array('field' => 'some_other_field');
     $attributes['created'] = array();
     $expected = Hash::normalize($attributes);
     $expected['someAttribute']['type'] = 'int';
     $expected['someOtherAttribute']['type'] = 'string';
     $expected['created'] = array('field' => 'created', 'type' => 'datetime');
     $result = $this->ApiBehavior->attributes($this->TestModel, $attributes);
     $this->assertEquals($expected, $result);
     $result = $this->ApiBehavior->attributes($this->TestModel);
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:23,代码来源:ApiBehaviorTest.php

示例14: _walkMap

 /**
  * ApiComponent::$recordMapを走査するためのヘルパーメソッドです。
  *
  * @param callable $callback
  * @return void
  */
 protected function _walkMap(callable $callback)
 {
     foreach ($this->recordMap as $alias => $map) {
         $map = Hash::normalize($map);
         $wrap = null;
         if (array_key_exists('_wrap', $map)) {
             $wrap = $map['_wrap'];
             unset($map['_wrap']);
         }
         foreach ($map as $recordField => $paramsField) {
             if (!is_array($paramsField) && !$paramsField) {
                 $paramsField = $recordField;
             }
             $callback($paramsField, $alias, $recordField, $wrap);
         }
     }
 }
开发者ID:hiromi2424,项目名称:api,代码行数:23,代码来源:ApiComponent.php

示例15: config

 /**
  * Normalizes and sets config options as properties
  */
 public function config()
 {
     if (empty($this->options['models'])) {
         return;
     }
     $this->models = Hash::normalize($this->options['models']);
     if (isset($this->options['prependPk'])) {
         $this->prependPk = $this->options['prependPk'];
     }
     if (isset($this->options['slugFunction'])) {
         $this->slugFunction = $this->options['slugFunction'];
     }
 }
开发者ID:jeremyharris,项目名称:slugger,代码行数:16,代码来源:SluggableRoute.php


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