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


PHP Hash::remove方法代码示例

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


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

示例1: testRemoveMulti

 /**
  * Test removing multiple values.
  *
  * @return void
  */
 public function testRemoveMulti()
 {
     $data = static::articleData();
     $result = Hash::remove($data, '{n}.Article.title');
     $this->assertFalse(isset($result[0]['Article']['title']));
     $this->assertFalse(isset($result[1]['Article']['title']));
     $result = Hash::remove($data, '{n}.Article.{s}');
     $this->assertFalse(isset($result[0]['Article']['id']));
     $this->assertFalse(isset($result[0]['Article']['user_id']));
     $this->assertFalse(isset($result[0]['Article']['title']));
     $this->assertFalse(isset($result[0]['Article']['body']));
     $data = [0 => ['Item' => ['id' => 1, 'title' => 'first']], 1 => ['Item' => ['id' => 2, 'title' => 'second']], 2 => ['Item' => ['id' => 3, 'title' => 'third']], 3 => ['Item' => ['id' => 4, 'title' => 'fourth']], 4 => ['Item' => ['id' => 5, 'title' => 'fifth']]];
     $result = Hash::remove($data, '{n}.Item[id=/\\b2|\\b4/]');
     $expected = [0 => ['Item' => ['id' => 1, 'title' => 'first']], 2 => ['Item' => ['id' => 3, 'title' => 'third']], 4 => ['Item' => ['id' => 5, 'title' => 'fifth']]];
     $this->assertEquals($expected, $result);
     $data[3]['testable'] = true;
     $result = Hash::remove($data, '{n}[testable].Item[id=/\\b2|\\b4/].title');
     $expected = [0 => ['Item' => ['id' => 1, 'title' => 'first']], 1 => ['Item' => ['id' => 2, 'title' => 'second']], 2 => ['Item' => ['id' => 3, 'title' => 'third']], 3 => ['Item' => ['id' => 4], 'testable' => true], 4 => ['Item' => ['id' => 5, 'title' => 'fifth']]];
     $this->assertEquals($expected, $result);
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:25,代码来源:HashTest.php

示例2: delete

 /**
  * Removes a variable from session.
  *
  * @param string $name Session variable to remove
  * @return void
  */
 public function delete($name)
 {
     if ($this->check($name)) {
         $this->_overwrite($_SESSION, Hash::remove($_SESSION, $name));
     }
 }
开发者ID:cakephp,项目名称:cakephp,代码行数:12,代码来源:Session.php

示例3: delete

 /**
  * Delete a cookie value
  *
  * You must use this method before any output is sent to the browser.
  * Failure to do so will result in header already sent errors.
  *
  * Deleting a top level key will delete all keys nested within that key.
  * For example deleting the `User` key, will also delete `User.email`.
  *
  * @param string $key Key of the value to be deleted
  * @return void
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete
  */
 public function delete($key)
 {
     $this->_load($key);
     $this->_values = Hash::remove($this->_values, $key);
     $parts = explode('.', $key);
     $top = $parts[0];
     if (isset($this->_values[$top])) {
         $this->_write($top, $this->_values[$top]);
     } else {
         $this->_delete($top);
     }
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:25,代码来源:CookieComponent.php

示例4: delete

 /**
  * Used to delete a variable from Configure.
  *
  * Usage:
  * ```
  * Configure::delete('Name'); will delete the entire Configure::Name
  * Configure::delete('Name.key'); will delete only the Configure::Name[key]
  * ```
  *
  * @param string $var the var to be deleted
  * @return void
  * @link http://book.cakephp.org/3.0/en/development/configuration.html#deleting-configuration-data
  */
 public static function delete($var)
 {
     static::$_values = Hash::remove(static::$_values, $var);
 }
开发者ID:lhas,项目名称:pep,代码行数:17,代码来源:Configure.php

示例5: _uploadArrayPer

 /**
  * Extract from the request the given field and return it.
  *
  * @param  string $field name of the field to be extracted from the upload(s).
  * @return array|false
  */
 protected function _uploadArrayPer($field = '')
 {
     if (empty($field)) {
         $field = $this->_upField;
     }
     $data = $this->request->data;
     $uploadArray = Hash::get($data, 'UploadDocuments.file.' . $field);
     $data = Hash::remove($data, 'UploadDocuments.file' . $field);
     if (empty($uploadArray)) {
         return false;
     }
     $data = Hash::insert($data, 'UploadDocuments.file', $uploadArray);
     return $data;
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:20,代码来源:CsvMigrationUploadTrait.php

示例6: delete

 /**
  * Used to cache delete a key from Setting.
  *
  * Usage:
  * ```
  * Setting::delete('Name'); will delete the entire Setting::Name
  * Setting::delete('Name.key'); will delete only the Setting::Name[key]
  * ```
  *
  * @param string $key the key to be deleted
  * @return void
  */
 public static function delete($key)
 {
     self::$_data = Hash::remove(self::$_data, $key);
 }
开发者ID:crabstudio,项目名称:app,代码行数:16,代码来源:Setting.php

示例7: remove

 /**
  * Remove the data at the specified path from the tool set
  * 
  * @param string $path
  * @return array
  */
 public function remove($path)
 {
     return Hash::remove($this->_tools, $path);
 }
开发者ID:OrigamiStructures,项目名称:CrudViews,代码行数:10,代码来源:ActionPattern.php

示例8: Loader

<?php

use Cake\Utility\Hash;
use josegonzalez\Dotenv\Loader;
$config = [];
if (!env('APP_NAME')) {
    $dotenv = new Loader([__DIR__ . DS . '.env', __DIR__ . DS . '.env.default']);
    $dotenv->setFilters(['josegonzalez\\Dotenv\\Filter\\LowercaseKeyFilter', 'josegonzalez\\Dotenv\\Filter\\UppercaseFirstKeyFilter', 'josegonzalez\\Dotenv\\Filter\\UnderscoreArrayFilter', function ($data) {
        $keys = ['Debug' => 'debug', 'Emailtransport' => 'EmailTransport', 'Database' => 'Datasources.default', 'Test.database' => 'Datasources.test', 'Test' => null, 'Cache.duration' => null, 'Cache.cakemodel' => 'Cache._cake_model_', 'Cache.cakecore' => 'Cache._cake_core_'];
        foreach ($keys as $key => $newKey) {
            if ($newKey === null) {
                $data = Hash::remove($data, $key);
                continue;
            }
            $value = Hash::get($data, $key);
            $data = Hash::remove($data, $key);
            $data = Hash::insert($data, $newKey, $value);
        }
        return $data;
    }]);
    $dotenv->parse();
    $dotenv->filter();
    $config = $dotenv->toArray();
}
return $config;
开发者ID:themogwi,项目名称:app,代码行数:25,代码来源:env.php

示例9: consume

 /**
  * Used to read and delete a variable from Configure.
  *
  * This is primarily used during bootstrapping to move configuration data
  * out of configure into the various other classes in CakePHP.
  *
  * @param string $var The key to read and remove.
  * @return array|null
  */
 public static function consume($var)
 {
     $simple = strpos($var, '.') === false;
     if ($simple && !isset(static::$_values[$var])) {
         return null;
     }
     if ($simple) {
         $value = static::$_values[$var];
         unset(static::$_values[$var]);
         return $value;
     }
     $value = Hash::get(static::$_values, $var);
     static::$_values = Hash::remove(static::$_values, $var);
     return $value;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:24,代码来源:Configure.php

示例10: testRemoveMulti

 /**
  * Test removing multiple values.
  *
  * @return void
  */
 public function testRemoveMulti()
 {
     $data = static::articleData();
     $result = Hash::remove($data, '{n}.Article.title');
     $this->assertFalse(isset($result[0]['Article']['title']));
     $this->assertFalse(isset($result[1]['Article']['title']));
     $result = Hash::remove($data, '{n}.Article.{s}');
     $this->assertFalse(isset($result[0]['Article']['id']));
     $this->assertFalse(isset($result[0]['Article']['user_id']));
     $this->assertFalse(isset($result[0]['Article']['title']));
     $this->assertFalse(isset($result[0]['Article']['body']));
     $data = array(0 => array('Item' => array('id' => 1, 'title' => 'first')), 1 => array('Item' => array('id' => 2, 'title' => 'second')), 2 => array('Item' => array('id' => 3, 'title' => 'third')), 3 => array('Item' => array('id' => 4, 'title' => 'fourth')), 4 => array('Item' => array('id' => 5, 'title' => 'fifth')));
     $result = Hash::remove($data, '{n}.Item[id=/\\b2|\\b4/]');
     $expected = array(0 => array('Item' => array('id' => 1, 'title' => 'first')), 2 => array('Item' => array('id' => 3, 'title' => 'third')), 4 => array('Item' => array('id' => 5, 'title' => 'fifth')));
     $this->assertEquals($expected, $result);
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:21,代码来源:HashTest.php

示例11: delete

 /**
  * Delete a cookie value
  *
  * Optional [Name.], required key
  * $this->Cookie->delete('Name.key);
  *
  * You must use this method before any output is sent to the browser.
  * Failure to do so will result in header already sent errors.
  *
  * This method will delete both the top level and 2nd level cookies set.
  * For example assuming that $name = App, deleting `User` will delete
  * both `App[User]` and any other cookie values like `App[User][email]`
  * This is done to clean up cookie storage from before 2.4.3, where cookies
  * were stored inconsistently.
  *
  * @param string $key Key of the value to be deleted
  * @return void
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete
  */
 public function delete($key)
 {
     $cookieName = $this->config('name');
     if (empty($this->_values[$cookieName])) {
         $this->read();
     }
     if (strpos($key, '.') === false) {
         if (isset($this->_values[$cookieName][$key]) && is_array($this->_values[$cookieName][$key])) {
             foreach ($this->_values[$cookieName][$key] as $idx => $val) {
                 $this->_delete("[{$key}][{$idx}]");
             }
         }
         $this->_delete("[{$key}]");
         unset($this->_values[$cookieName][$key]);
         return;
     }
     $names = explode('.', $key, 2);
     if (isset($this->_values[$cookieName][$names[0]])) {
         $this->_values[$cookieName][$names[0]] = Hash::remove($this->_values[$cookieName][$names[0]], $names[1]);
     }
     $this->_delete('[' . implode('][', $names) . ']');
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:41,代码来源:CookieComponent.php

示例12: delete

 /**
  * Removes a variable from session.
  *
  * @param string $name Session variable to remove
  * @return bool Success
  */
 public static function delete($name)
 {
     if (static::check($name)) {
         static::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
         return !static::check($name);
     }
     return false;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:14,代码来源:Session.php

示例13: remove

 /**
  * Remove a menu item.
  *
  * @param string $path dot separated path in the array.
  * @return void
  */
 public static function remove($path)
 {
     self::$_items = Hash::remove(self::$_items, $path);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:10,代码来源:Nav.php

示例14: section

 public function section()
 {
     $settings = TableRegistry::get('Settings');
     $users = TableRegistry::get('Users');
     $sectionForm = new SectionForm();
     $session = $this->request->session();
     $now = Time::now();
     $user = $users->get($this->Auth->user('id'));
     if ($this->request->is('get')) {
         $apiId = $settings->get('10')->text;
         $apiToken = $settings->get('11')->text;
         $apiBase = $settings->get('12')->text;
         if (empty($user->osm_secret) || !$session->check('OSM.Secret')) {
             $this->Flash->error(__('Please link your account first'));
             return $this->redirect(['action' => 'link']);
         } else {
             $userOsmId = $user->osm_user_id;
             $userOsmSecret = $user->osm_secret . $session->read('OSM.Secret');
         }
         $http = new Client(['host' => $apiBase, 'scheme' => 'https']);
         $url = '/api.php?action=getUserRoles';
         $response = $http->post($url, ['userid' => $userOsmId, 'secret' => $userOsmSecret, 'token' => $apiToken, 'apiid' => $apiId]);
         if ($response->isOk()) {
             $body = $response->json;
             $this->set(compact('body'));
             $body = Hash::remove($body, '{n}.sectionConfig');
             $body = Hash::remove($body, '{n}.permissions');
             $hsec = Hash::combine($body, '{n}.sectionid', '{n}.sectionname');
             $this->set(compact('hsec'));
         } else {
             $this->Flash->error(__('There was a request error, please try again.'));
             return $this->redirect(['action' => 'home']);
         }
     }
     if ($this->request->is('post')) {
         $osmSection = $this->request->data['osm_section'];
         $usrData = ['osm_section_id' => $osmSection, 'osm_linked' => 2];
         $users->patchEntity($user, $usrData);
         if ($users->save($user)) {
             $this->Flash->success(__('You have selected your OSM section.'));
             if (!empty($user->osm_current_term) && $user->osm_term_end > $now) {
                 return $this->redirect(['action' => 'home']);
             } else {
                 return $this->redirect(['action' => 'term']);
             }
         } else {
             $this->Flash->error(__('The user could not be saved. Please, try again.'));
         }
     }
     $this->set(compact('sectionForm'));
 }
开发者ID:CubScoutCake,项目名称:CubEventBooking,代码行数:51,代码来源:OsmController.php


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