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


PHP Hash::insert方法代码示例

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


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

示例1: before

 /**
  * Before migration callback
  *
  * @param string $direction Direction of migration process (up or down)
  * @return bool Should process continue
  */
 public function before($direction)
 {
     if ($direction === 'up') {
         $Model = ClassRegistry::init('SiteManager.SiteSetting');
         $dataSource = $Model->getDataSource();
         $searchType = SiteSetting::DATABASE_SEARCH_LIKE;
         $hasMroonga = false;
         if ($dataSource->config['datasource'] === 'Database/Mysql') {
             $result = $Model->query('SELECT * FROM information_schema.ENGINES');
             $engines = Hash::extract($result, '{n}.ENGINES.ENGINE');
             $mysql56 = (bool) version_compare($dataSource->getVersion(), '5.6', '>=');
             if ($mysql56) {
                 $searchType = SiteSetting::DATABASE_SEARCH_MATCH_AGAIN;
             } elseif (in_array('Mroonga', $engines, true)) {
                 //$searchType = 'match_against';
                 //$hasMroonga = true;
             }
         }
         if ($searchType === SiteSetting::DATABASE_SEARCH_LIKE) {
             //インデックスが使われないため、検索用のインデックス(FullText)は削除する
             $this->migration = Hash::remove($this->migration, 'up.create_table.topics.indexes.search');
         }
         if (!$hasMroonga) {
             $this->migration = Hash::insert($this->migration, 'up.create_table.topics.tableParameters.engine', 'InnoDB');
             $this->migration = Hash::remove($this->migration, 'up.create_table.topics.tableParameters.comment', null);
         }
         $record = array('language_id' => 0, 'key' => 'Search.type', 'value' => $searchType);
         $Model->create();
         if (!$Model->save($record, false)) {
             return false;
         }
     }
     return true;
 }
开发者ID:s-nakajima,项目名称:Topics,代码行数:40,代码来源:1462148437_init.php

示例2: beforeSave

 public function beforeSave($options = [])
 {
     $id = Hash::get($this->data, $this->name . '.id');
     $updateRules = [];
     $readFields = [];
     foreach (Hash::extract($this->data, $this->name) as $field => $value) {
         foreach ($this->rules as $key => $rule) {
             if ($rule[3] == false && array_search($this->name . '.' . $field, $rule[1]) !== FALSE) {
                 $this->rules[$key][3] = true;
                 $readFields = array_merge($readFields, $rule[1]);
             }
         }
     }
     if (!empty($readFields)) {
         $this->save(null, ['callbacks' => false]);
         $id = $this->id;
         $this->read(array_unique($readFields), $id);
         foreach ($this->rules as $rule) {
             if ($rule[3]) {
                 $values = [];
                 foreach ($rule[1] as $depend) {
                     $value = Hash::get($this->data, $depend);
                     $values[] = $value;
                 }
                 $this->data = Hash::insert($this->data, $rule[0], $rule[2]($values));
             }
         }
     }
     return true;
 }
开发者ID:ukatama,项目名称:beniimo-trpg-locale,代码行数:30,代码来源:AutoCalcModel.php

示例3: add

 /**
  * Adds a new item to a menu
  *
  * @param string $menu The menu alias
  * @param string $key
  * @param string $label
  * @param array $options
  * @return void
  */
 public function add($menu, $key, $label = null, $url = null, $options = array())
 {
     if (is_array($key)) {
         foreach ($key as $k => $item) {
             if (is_string($k)) {
                 $item['key'] = $k;
             }
             $item = array_merge(array('url' => null, 'options' => array()), $item);
             $this->add($menu, $item['key'], $item['label'], $item['url'], $item['options']);
         }
         return;
     }
     $path = array();
     if (strpos($menu, '.') !== false) {
         $path = explode('.', $menu);
         $menu = $path[0];
     } else {
         $path = array($menu);
     }
     if (!array_key_exists($menu, $this->_menus)) {
         $this->create($menu);
     }
     $subitems = array();
     if (!empty($options['items'])) {
         $subitems = $options['items'];
         unset($options['items']);
     }
     $item = array('label' => $label, 'url' => $url, 'options' => $options);
     $hashPath = implode($path, '.items.') . '.items.' . $key;
     $this->_menus = Hash::insert($this->_menus, $hashPath, $item);
     if (!empty($subitems)) {
         $submenuKey = implode($path, '.') . '.' . $key;
         $this->add($submenuKey, $subitems);
     }
 }
开发者ID:jellehenkens,项目名称:CakeMenu,代码行数:44,代码来源:CakeMenuHelper.php

示例4: beforeFilter

 public function beforeFilter()
 {
     $this->Maintenance->checkMaintenance();
     $this->Cookie->name = APP_NAME;
     $this->Cookie->type('rijndael');
     if (isset($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin') {
         $this->layout = 'admin';
         $this->Auth->authenticate = Hash::insert($this->Auth->authenticate, "{s}.scope", array('User.is_admin' => 1));
         $this->Auth->loginAction = array('prefix' => 'admin', 'plugin' => '', 'controller' => 'user', 'action' => 'login');
         $this->Auth->loginRedirect = array('prefix' => 'admin', 'plugin' => '', 'controller' => 'dashboard', 'action' => 'index');
         $this->Auth->logoutRedirect = '/admin';
         $this->Auth->flash = array('element' => 'alert', 'key' => 'auth', 'params' => array('plugin' => 'BoostCake', 'class' => 'alert-error'));
         $this->helpers['Html'] = array('className' => 'BoostCake.BoostCakeHtml');
         $this->helpers['Form'] = array('className' => 'BoostCake.BoostCakeForm');
         $this->helpers['Paginator'] = array('className' => 'BoostCake.BoostCakePaginator');
     }
     $this->_checkAuth();
     if (!$this->Auth->loggedIn() && !in_array($this->request->params['action'], array('register', 'login', 'fbAuth', 'fbAuthCheck', 'confirm', 'forgetPassword', 'passwordRequest', 'ipnPaypal'))) {
         $this->layout = 'unregistered';
         $this->set('currUserID', $this->currUserID);
         $this->set('currUser', $this->currUser);
     }
     $this->Auth->authError = __('You must log in to access this page');
     $this->Auth->allow(array('register', 'login', 'fbAuth', 'fbAuthCheck', 'fbAccessToken', 'confirm', 'forgetPassword', 'passwordRequest', 'ipnPaypal', 'error404', 'vacancies'));
     //        $this->_checkAuth();
     $this->_updateUser();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:27,代码来源:AppController.php

示例5: afterFind

 public function afterFind($results, $primary = false)
 {
     if ($primary) {
         $results = Hash::insert($results, "{n}.BraintreeSubscription", array());
         $results = Hash::insert($results, "{n}.BraintreePlan", array());
         $braintreeSubscriptions = Braintree_Subscription::search([Braintree_SubscriptionSearch::ids()->in(Hash::extract($results, "{n}.BillingSubscription.remote_subscription_id"))]);
         $braintreePlans = Braintree_Plan::all();
         foreach ($results as $key => $result) {
             foreach ($braintreeSubscriptions as $braintreeSubscription) {
                 if ($braintreeSubscription->id == $result['BillingSubscription']['remote_subscription_id']) {
                     $result['BraintreeSubscription'] = $braintreeSubscription;
                     break;
                 }
                 //$results = Hash::insert($results, "{n}.BillingSubscription[remote_subscription_id=".$braintreeSubscription->id."]", array('BraintreeSubscription' => $braintreeSubscription));
             }
             foreach ($braintreePlans as $braintreePlan) {
                 if ($braintreePlan->id == $result['BillingSubscription']['remote_plan_id']) {
                     $result['BraintreePlan'] = $braintreePlan;
                     break;
                 }
             }
             $results[$key] = $result;
         }
     }
     return $results;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:26,代码来源:BillingSubscription.php

示例6: addSubMenu

 public static function addSubMenu($parentSlug, $slug, $title, $url, $capability)
 {
     if (self::menuExists($parentSlug)) {
         if (!self::subMenuExists($parentSlug, $slug)) {
             self::$menus = Hash::insert(self::$menus, $parentSlug . '.sub_menus.' . $slug, array('title' => $title, 'url' => $url, 'capability' => $capability));
         }
     }
 }
开发者ID:hurad,项目名称:hurad,代码行数:8,代码来源:HuradNavigation.php

示例7: setState

 public function setState($key, $value, $defaultValue = null)
 {
     $current = isset($_SESSION[$this->sessionVariable]) ? $_SESSION[$this->sessionVariable] : array();
     if ($value === $defaultValue) {
         $_SESSION[$this->sessionVariable] = Hash::remove($current, $key);
     } else {
         $_SESSION[$this->sessionVariable] = Hash::insert($current, $key, $value);
     }
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:9,代码来源:LSWebUser.php

示例8: admin_save

 /**
  * Saves dashboard setting
  *
  * @return void
  */
 public function admin_save()
 {
     $userId = $this->Auth->user('id');
     if (!$userId) {
         throw new CakeException('You must be logged in');
     }
     $data = Hash::insert($this->request->data['dashboard'], '{n}.user_id', $userId);
     $this->DashboardsDashboard->deleteAll(array('user_id' => $userId));
     $this->DashboardsDashboard->saveMany($data);
 }
开发者ID:saydulk,项目名称:croogo,代码行数:15,代码来源:DashboardsDashboardsController.php

示例9: write

 public static function write($config, $value = null)
 {
     if (!is_object(self::$singletoninstance)) {
         self::singleton();
     }
     if (!is_array($config)) {
         $config = array($config => $value);
     }
     foreach ($config as $name => $value) {
         self::$confList = Hash::insert(self::$confList, $name, $value);
     }
     $_SESSION['cacheConfig'] = self::$confList;
 }
开发者ID:thantalas,项目名称:slim-nne,代码行数:13,代码来源:Configure.php

示例10: blockTitle

 /**
  * タイトル(ブロックタイトル)の出力
  *
  * #### サンプル
  * ```
  * echo $this->NetCommonsHtml->blockTitle($bbs['name'])
  * ```
  * ##### 出力結果
  * ```
  * <h1>新しい掲示板 20160513074815</h1>
  * ```
  *
  * @param string $text タイトル
  * @param string $titleIcon タイトルアイコン
  * @param array $options HTML属性オプション
  * @return string `<h1>`タグ
  */
 public function blockTitle($text = '', $titleIcon = null, $options = array())
 {
     $output = '';
     $escape = Hash::get($options, 'escape', true);
     if ($escape) {
         $text = h($text);
     }
     $options = Hash::insert($options, 'escape', false);
     if ($titleIcon) {
         $text = $this->NetCommonsHtml->titleIcon($titleIcon) . ' ' . $text;
     }
     $output .= $this->Html->tag('h1', $text, $options);
     return $output;
 }
开发者ID:akagane99,项目名称:Blocks,代码行数:31,代码来源:BlocksHelper.php

示例11: testSaveFile

 /**
  * Expect FileModel->saveFile() on success
  *
  * @return void
  */
 public function testSaveFile()
 {
     //データ生成
     $data = array('File' => array('status' => 1, 'role_type' => 'file_test', 'path' => TMP . 'tests' . DS . 'files' . DS, 'slug' => 'file_test_1', 'extension' => 'gif', 'original_name' => 'file_test_1', 'mimetype' => 'image/gif', 'name' => 'logo.gif', 'alt' => 'logo.gif', 'size' => 5873), 'FilesPlugin' => array('plugin_key' => 'files'), 'FilesRoom' => array('room_id' => 1), 'FilesUser' => array('user_id' => 1));
     $this->FileModel->saveFile($data);
     //期待値の生成
     $fileId = 2;
     $expected = $data;
     $expected = Hash::insert($expected, '{s}.file_id', $fileId);
     $expected['File']['id'] = $expected['File']['file_id'];
     unset($expected['File']['file_id']);
     $result = $this->FileModel->findById($fileId);
     $result['FilesPlugin'] = $result['FilesPlugin'][0];
     $result['FilesRoom'] = $result['FilesRoom'][0];
     $result['FilesUser'] = $result['FilesUser'][0];
     $this->_assertArray(null, $expected, $result);
 }
开发者ID:Onasusweb,项目名称:Files,代码行数:22,代码来源:FileModelTest.php

示例12: write

 /**
  * @param $name
  * @param $value
  * @return bool
  */
 public function write($name, $value)
 {
     if (empty($name)) {
         return false;
     }
     $write = $name;
     if (!is_array($name)) {
         $write = array($name => $value);
     }
     foreach ($write as $key => $val) {
         self::_overwrite($this->data, Hash::insert($this->data, $key, $val));
         if (Hash::get($this->data, $key) !== $val) {
             return false;
         }
     }
     return true;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:22,代码来源:SessionStub.php

示例13: testValidateErrorByRssReader

 /**
  * Expect RssReaderItem->updateRssReaderItems() validate error by RssReader
  *
  * @return void
  */
 public function testValidateErrorByRssReader()
 {
     $rssReaderId = 1;
     //コンテンツの公開権限true
     $this->RssReader->Behaviors->attach('Publishable');
     $this->RssReader->Behaviors->Publishable->setup($this->RssReader, ['contentPublishable' => true]);
     //データ生成
     $rssReader = $this->RssReader->find('first', array('recursive' => -1, 'conditions' => array('id' => $rssReaderId)));
     $rssReader['RssReader']['url'] = '';
     $url = APP . 'Plugin' . DS . 'RssReaders' . DS . 'Test' . DS . 'Fixture' . DS . 'rss_v1.xml';
     $xmlData = $this->RssReaderItem->serializeXmlToArray($url);
     $xmlData = Hash::insert($xmlData, '{n}.rss_reader_id', $rssReaderId);
     $data = array('RssReader' => $rssReader['RssReader'], 'RssReaderItem' => $xmlData);
     //登録処理実行
     $result = $this->RssReaderItem->updateRssReaderItems($data);
     //テスト実施(詳細なバリデーションのチェックは、RssReaderValidateErrorTestで行う)
     $this->assertFalse($result);
 }
开发者ID:Onasusweb,项目名称:RssReaders,代码行数:23,代码来源:RssReaderItemUpdateRssReaderItemsTest.php

示例14: saveDefaultUserAttributesRole

 /**
  * Save default UserAttributesRole
  *
  * @param Model $model Model using this behavior
  * @param array $data User role data
  * @return bool True on success
  * @throws InternalErrorException
  */
 public function saveDefaultUserAttributesRole(Model $model, $data)
 {
     $model->loadModels(['UserAttributesRole' => 'UserRoles.UserAttributesRole']);
     //UserAttributesRoleデフォルトのデータ取得
     $userAttributesRole = $model->UserAttributesRole->find('all', array('recursive' => -1, 'conditions' => array('role_key' => $data['UserRoleSetting']['origin_role_key'])));
     if (!$userAttributesRole) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     //UserAttributesRoleの登録処理
     foreach (['id', 'created', 'created_user', 'modified', 'modified_user'] as $field) {
         $userAttributesRole = Hash::remove($userAttributesRole, '{n}.UserAttributesRole.' . $field);
     }
     $userAttributesRole = Hash::insert($userAttributesRole, '{n}.UserAttributesRole.role_key', $data['UserRoleSetting']['role_key']);
     if (!$model->UserAttributesRole->saveMany($userAttributesRole, array('validate' => false))) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     return true;
 }
开发者ID:NetCommons3,项目名称:UserRoles,代码行数:26,代码来源:UserRoleBehavior.php

示例15: camelizeKeyRecursive

 /**
  * Camelize処理
  *
  * @param array $orig 変換元データ
  * @return array 変換後データ
  */
 public function camelizeKeyRecursive($orig)
 {
     $newResult = [];
     foreach ($orig as $key => $value) {
         if (Hash::get($value, 'TrackableCreator')) {
             $avatar = $this->DisplayUser->avatar($value, [], 'TrackableCreator.id');
             $value = Hash::insert($value, 'TrackableCreator.avatar', $avatar);
         }
         if (Hash::get($value, 'TrackableUpdater')) {
             $avatar = $this->DisplayUser->avatar($value, [], 'TrackableUpdater.id');
             $value = Hash::insert($value, 'TrackableUpdater.avatar', $avatar);
         }
         $newResult[$key] = $this->__camelizeKeyRecursive($value);
         $displayStatus = $this->__getStatusLabel($newResult[$key]);
         $newResult[$key]['topic']['displayStatus'] = $displayStatus;
     }
     return $newResult;
 }
开发者ID:s-nakajima,项目名称:Topics,代码行数:24,代码来源:TopicsHelper.php


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