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


PHP Hash::expand方法代码示例

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


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

示例1: index

 /**
  * Index method
  *
  * @return void
  */
 public function index()
 {
     if ($this->request->is(['post', 'put'])) {
         $settings = $this->Settings->find('all')->all();
         $settings = $this->Settings->patchEntities($settings, $this->request->data()['Setting']);
         $result = $this->Settings->connection()->transactional(function () use($settings) {
             foreach ($settings as $setting) {
                 $result = $this->Settings->save($setting, ['atomic' => false]);
                 if (!$result) {
                     return false;
                 }
             }
             return true;
         });
         if ($result) {
             $settings = $this->Settings->find()->combine('path', 'value')->toArray();
             ksort($settings);
             $settings = Hash::expand($settings);
             Settings::dump('config', 'default', $settings);
             $this->Flash->success('The settings has been saved.');
             $this->redirect(['action' => 'index']);
         } else {
             $this->Flash->error('The settings could not be saved. Please, try again.');
         }
     }
     $settings = $this->Settings->find('extended')->find('editable')->toArray();
     $this->set('settings', $settings['editable']);
 }
开发者ID:mindforce,项目名称:cakephp-rear-engine,代码行数:33,代码来源:SettingsController.php

示例2: import

 public function import()
 {
     $settingsFile = 'settings';
     if (!empty($this->plugin)) {
         $settingsFile = $this->plugin . '.' . $settingsFile;
         $settingsFileDir = Plugin::path($this->plugin) . 'config';
     } else {
         $settingsFileDir = ROOT . DS . 'config';
     }
     $settingsDir = new Folder($settingsFileDir, false);
     if (!$settingsDir->find('settings.*')) {
         return false;
     }
     $config = new PhpConfig();
     $data = $config->read($settingsFile);
     if (!$data) {
         return false;
     }
     if (!empty($this->plugin)) {
         $this->out(__d('platform', '- <success>Processing settings pool for {0} plugin</success>', $this->plugin));
     } else {
         $this->out(__d('platform', '- <success>Processing settings pool for {0}</success>', 'App'));
     }
     $settingsTable = TableRegistry::get('Platform.Settings');
     foreach ($data as $row) {
         if (!isset($row['plugin']) || empty($row['plugin'])) {
             $row['plugin'] = $this->plugin;
         }
         $data = ['plugin' => $row['plugin'], 'path' => $row['path']];
         $setting = $settingsTable->find('all', ['conditions' => $data])->first();
         if (!$setting) {
             $setting = $settingsTable->newEntity();
             $data = array_merge($data, ['value' => isset($row['default']) ? $row['default'] : '']);
         }
         $setting = $settingsTable->patchEntity($setting, $data);
         $settingsTable->save($setting);
     }
     //TODO: Maybe chared method for settings save
     $settings = $settingsTable->find()->combine('path', 'value')->toArray();
     ksort($settings);
     $settings = Hash::expand($settings);
     Settings::dump('config', 'default', $settings);
 }
开发者ID:mindforce,项目名称:cakephp-platform,代码行数:43,代码来源:SettingsTask.php

示例3: getAllKeyValues

 /**
  * Returns all keys and their values for all scopes.
  *
  * @return array
  */
 public function getAllKeyValues()
 {
     $query = $this->_table->query();
     $query->formatResults(function (ResultSet $results) {
         return $results->map(function ($row) {
             if ($row['serialized'] === true) {
                 $row['value'] = unserialize($row['value']);
             }
             return $row;
         });
     });
     $settings = [];
     foreach ($query->all() as $row) {
         $key = $row['scope'] . '__' . $row[$this->config('fields.key')];
         $value = $row[$this->config('fields.value')];
         $settings[$key] = $value;
     }
     return Hash::expand($settings, '__');
 }
开发者ID:wasabi-cms,项目名称:core,代码行数:24,代码来源:KeyValueBehavior.php

示例4: testFlattenInfiniteLoop

 /**
  * Test that flattening a large complex set doesn't loop forever.
  *
  * @return void
  */
 public function testFlattenInfiniteLoop()
 {
     $data = ['Order.ASI' => '0', 'Order.Accounting' => '0', 'Order.Admin' => '0', 'Order.Art' => '0', 'Order.ArtChecker' => '0', 'Order.Canned' => '0', 'Order.Customer_Tags' => '', 'Order.Embroidery' => '0', 'Order.Item.0.Product.style_number' => 'a11222', 'Order.Item.0.Product.slug' => 'a11222', 'Order.Item.0.Product._id' => '4ff8b8d3d7bbe8ad30000000', 'Order.Item.0.Product.Color.slug' => 'kelly_green', 'Order.Item.0.Product.ColorSizes.0.Color.color' => 'Sport Grey', 'Order.Item.0.Product.ColorSizes.0.Color.slug' => 'sport_grey', 'Order.Item.0.Product.ColorSizes.1.Color.color' => 'Kelly Green', 'Order.Item.0.Product.ColorSizes.1.Color.slug' => 'kelly_green', 'Order.Item.0.Product.ColorSizes.2.Color.color' => 'Orange', 'Order.Item.0.Product.ColorSizes.2.Color.slug' => 'orange', 'Order.Item.0.Product.ColorSizes.3.Color.color' => 'Yellow Haze', 'Order.Item.0.Product.ColorSizes.3.Color.slug' => 'yellow_haze', 'Order.Item.0.Product.brand' => 'OUTER BANKS', 'Order.Item.0.Product.style' => 'T-shirt', 'Order.Item.0.Product.description' => 'uhiuhuih oin ooi ioo ioio', 'Order.Item.0.Product.sizes.0.Size.qty' => '', 'Order.Item.0.Product.sizes.0.Size.size' => '0-3mo', 'Order.Item.0.Product.sizes.0.Size.id' => '38', 'Order.Item.0.Product.sizes.1.Size.qty' => '', 'Order.Item.0.Product.sizes.1.Size.size' => '3-6mo', 'Order.Item.0.Product.sizes.1.Size.id' => '39', 'Order.Item.0.Product.sizes.2.Size.qty' => '78', 'Order.Item.0.Product.sizes.2.Size.size' => '6-9mo', 'Order.Item.0.Product.sizes.2.Size.id' => '40', 'Order.Item.0.Product.sizes.3.Size.qty' => '', 'Order.Item.0.Product.sizes.3.Size.size' => '6-12mo', 'Order.Item.0.Product.sizes.3.Size.id' => '41', 'Order.Item.0.Product.sizes.4.Size.qty' => '', 'Order.Item.0.Product.sizes.4.Size.size' => '12-18mo', 'Order.Item.0.Product.sizes.4.Size.id' => '42', 'Order.Item.0.Art.imprint_locations.0.id' => 2, 'Order.Item.0.Art.imprint_locations.0.name' => 'Left Chest', 'Order.Item.0.Art.imprint_locations.0.imprint_type.id' => 7, 'Order.Item.0.Art.imprint_locations.0.imprint_type.type' => 'Embroidery', 'Order.Item.0.Art.imprint_locations.0.art' => '', 'Order.Item.0.Art.imprint_locations.0.num_colors' => 3, 'Order.Item.0.Art.imprint_locations.0.description' => 'Wooo! This is Embroidery!!', 'Order.Item.0.Art.imprint_locations.0.lines.0' => 'Platen', 'Order.Item.0.Art.imprint_locations.0.lines.1' => 'Logo', 'Order.Item.0.Art.imprint_locations.0.height' => 4, 'Order.Item.0.Art.imprint_locations.0.width' => 5, 'Order.Item.0.Art.imprint_locations.0.stitch_density' => 'Light', 'Order.Item.0.Art.imprint_locations.0.metallic_thread' => true, 'Order.Item.0.Art.imprint_locations.1.id' => 4, 'Order.Item.0.Art.imprint_locations.1.name' => 'Full Back', 'Order.Item.0.Art.imprint_locations.1.imprint_type.id' => 6, 'Order.Item.0.Art.imprint_locations.1.imprint_type.type' => 'Screenprinting', 'Order.Item.0.Art.imprint_locations.1.art' => '', 'Order.Item.0.Art.imprint_locations.1.num_colors' => 3, 'Order.Item.0.Art.imprint_locations.1.description' => 'Wooo! This is Screenprinting!!', 'Order.Item.0.Art.imprint_locations.1.lines.0' => 'Platen', 'Order.Item.0.Art.imprint_locations.1.lines.1' => 'Logo', 'Order.Item.0.Art.imprint_locations.2.id' => 26, 'Order.Item.0.Art.imprint_locations.2.name' => 'HS - JSY Name Below', 'Order.Item.0.Art.imprint_locations.2.imprint_type.id' => 9, 'Order.Item.0.Art.imprint_locations.2.imprint_type.type' => 'Names', 'Order.Item.0.Art.imprint_locations.2.description' => 'Wooo! This is Names!!', 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.active' => 1, 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.name' => 'Benjamin Talavera', 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.color' => 'Red', 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.height' => '3', 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.layout' => 'Arched', 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.style' => 'Classic', 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.active' => 0, 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.name' => 'Rishi Narayan', 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.color' => 'Cardinal', 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.height' => '4', 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.layout' => 'Straight', 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.style' => 'Team US', 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.active' => 1, 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.name' => 'Brandon Plasters', 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.color' => 'Red', 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.height' => '3', 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.layout' => 'Arched', 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.style' => 'Classic', 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.active' => 0, 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.name' => 'Andrew Reed', 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.color' => 'Cardinal', 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.height' => '4', 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.layout' => 'Straight', 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.style' => 'Team US', 'Order.Job.0._id' => 'job-1', 'Order.Job.0.type' => 'screenprinting', 'Order.Job.0.postPress' => 'job-2', 'Order.Job.1._id' => 'job-2', 'Order.Job.1.type' => 'embroidery', 'Order.Postpress' => '0', 'Order.PriceAdjustment.0._id' => 'price-adjustment-1', 'Order.PriceAdjustment.0.adjustment' => '-20', 'Order.PriceAdjustment.0.adjustment_type' => 'percent', 'Order.PriceAdjustment.0.type' => 'grand_total', 'Order.PriceAdjustment.1.adjustment' => '20', 'Order.PriceAdjustment.1.adjustment_type' => 'flat', 'Order.PriceAdjustment.1.min-items' => '10', 'Order.PriceAdjustment.1.type' => 'min-items', 'Order.PriceAdjustment.1._id' => 'another-test-adjustment', 'Order.Purchasing' => '0', 'Order.QualityControl' => '0', 'Order.Receiving' => '0', 'Order.ScreenPrinting' => '0', 'Order.Stage.art_approval' => 0, 'Order.Stage.draft' => 1, 'Order.Stage.quote' => 1, 'Order.Stage.order' => 1, 'Order.StoreLiason' => '0', 'Order.Tag_UI_Email' => '', 'Order.Tags' => '', 'Order._id' => 'test-2', 'Order.add_print_location' => '', 'Order.created' => '2011-Dec-29 05:40:18', 'Order.force_admin' => '0', 'Order.modified' => '2012-Jul-25 01:24:49', 'Order.name' => 'towering power', 'Order.order_id' => '135961', 'Order.slug' => 'test-2', 'Order.title' => 'test job 2', 'Order.type' => 'ttt'];
     $expanded = Hash::expand($data);
     $flattened = Hash::flatten($expanded);
     $this->assertEquals($data, $flattened);
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:12,代码来源:HashTest.php

示例5: _configWrite

 /**
  * Write a config variable
  *
  * @param string|array $key Key to write to.
  * @param mixed $value Value to write.
  * @param bool|string $merge True to merge recursively, 'shallow' for simple merge,
  *   false to overwrite, defaults to false.
  * @return void
  * @throws \Cake\Core\Exception\Exception if attempting to clobber existing config
  */
 protected function _configWrite($key, $value, $merge = false)
 {
     if (is_string($key) && $value === null) {
         $this->_configDelete($key);
         return;
     }
     if ($merge) {
         $update = is_array($key) ? $key : [$key => $value];
         if ($merge === 'shallow') {
             $this->_config = array_merge($this->_config, Hash::expand($update));
         } else {
             $this->_config = Hash::merge($this->_config, Hash::expand($update));
         }
         return;
     }
     if (is_array($key)) {
         foreach ($key as $k => $val) {
             $this->_configWrite($k, $val);
         }
         return;
     }
     if (strpos($key, '.') === false) {
         $this->_config[$key] = $value;
         return;
     }
     $update =& $this->_config;
     $stack = explode('.', $key);
     foreach ($stack as $k) {
         if (!is_array($update)) {
             throw new Exception(sprintf('Cannot set %s value', $key));
         }
         if (!isset($update[$k])) {
             $update[$k] = [];
         }
         $update =& $update[$k];
     }
     $update = $value;
 }
开发者ID:Obo-project,项目名称:obo-project,代码行数:48,代码来源:InstanceConfigTrait.php

示例6: commands

 /**
  * Return a list of all commands
  *
  * @return array
  */
 public function commands()
 {
     $shellList = $this->getShellList();
     $flatten = Hash::flatten($shellList);
     $duplicates = array_intersect($flatten, array_unique(array_diff_key($flatten, array_unique($flatten))));
     $duplicates = Hash::expand($duplicates);
     $options = [];
     foreach ($shellList as $type => $commands) {
         foreach ($commands as $shell) {
             $prefix = '';
             if (!in_array(strtolower($type), ['app', 'core']) && isset($duplicates[$type]) && in_array($shell, $duplicates[$type])) {
                 $prefix = $type . '.';
             }
             $options[] = $prefix . $shell;
         }
     }
     return $options;
 }
开发者ID:tgr0ss,项目名称:cakephp,代码行数:23,代码来源:CommandTask.php

示例7: beforeMarshal

 /**
  * Triggered before data is converted into entities.
  *
  * Moves multi-value POST data into its corresponding column, for instance given
  * the following POST array:
  *
  * ```php
  * [
  *     'settings:max_time' => 10,
  *     'settings:color' => '#005599',
  *     'my_column:other_option' => 'some value',
  * ]
  * ```
  *
  * It becomes:
  *
  * ```php
  * [
  *     'settings' => [
  *         'max_time' => 10,
  *         'color' => '#005599',
  *     ],
  *     'my_column' => [
  *         'other_option' => 'some value',
  *     ]
  * ]
  * ```
  *
  * @param \Cake\Event\Event $event The event that was triggered
  * @param \ArrayObject $data The POST data to be merged with entity
  * @param \ArrayObject $options The options passed to the marshaller
  * @return void
  */
 public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
 {
     $dataArray = Hash::expand((array) $data, ':');
     foreach ($this->config('columns') as $column) {
         if (isset($dataArray[$column])) {
             $data[$column] = $dataArray[$column];
             if ($options['validate']) {
                 $eventName = $this->_table->alias() . ".{$column}.validate";
                 $columnData = (array) $dataArray[$column];
                 $this->_table->dispatchEvent($eventName, compact('columnData', 'options'));
             }
         }
     }
 }
开发者ID:quickapps-plugins,项目名称:cms,代码行数:47,代码来源:SerializableBehavior.php


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