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


PHP Hash::merge方法代码示例

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


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

示例1: config

 /**
  * Sets a configuration variable into this action
  *
  * If called with no arguments, all configuration values are
  * returned.
  *
  * $key is interpreted with dot notation, like the one used for
  * Configure::write()
  *
  * If $key is string and $value is not passed, it will return the
  * value associated with such key.
  *
  * If $key is an array and $value is empty, then $key will
  * be interpreted as key => value dictionary of settings and
  * it will be merged directly with $this->settings
  *
  * If $key is a string, the value will be inserted in the specified
  * slot as indicated using the dot notation
  *
  * @param mixed $key
  * @param mixed $value
  * @param boolean $merge
  * @return mixed|CrudAction
  */
 public function config($key = null, $value = null, $merge = true)
 {
     if ($key === null && $value === null) {
         return $this->_settings;
     }
     if ($value === null) {
         if (is_array($key)) {
             if ($merge) {
                 $this->_settings = Hash::merge($this->_settings, $key);
             } else {
                 foreach (Hash::flatten($key) as $k => $v) {
                     $this->_settings = Hash::insert($this->_settings, $k, $v);
                 }
             }
             return $this;
         }
         return Hash::get($this->_settings, $key);
     }
     if (is_array($value)) {
         if ($merge) {
             $value = array_merge((array) Hash::get($this->_settings, $key), $value);
         } else {
             foreach ($value as $k => $v) {
                 $this->_settings = Hash::insert($this->_settings, $k, $v);
             }
         }
     }
     $this->_settings = Hash::insert($this->_settings, $key, $value);
     return $this;
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:54,代码来源:CrudBaseObject.php

示例2: testSave

 /**
  * Save(公開)のテスト
  *
  * @param array $data 登録データ
  * @dataProvider dataProviderSave
  * @return array 登録後のデータ
  */
 public function testSave($data)
 {
     $model = $this->_modelName;
     $method = $this->_methodName;
     $created = !isset($data[$this->{$model}->alias]['id']);
     //チェック用データ取得
     if (!$created) {
         $before = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $data[$this->{$model}->alias]['id'])));
         $saveData = Hash::remove($data, $this->{$model}->alias . '.id');
     } else {
         $saveData = $data;
         $before[$this->{$model}->alias] = array();
     }
     //テスト実行
     $result = $this->{$model}->{$method}($saveData);
     $this->assertNotEmpty($result);
     $id = $this->{$model}->getLastInsertID();
     //is_latestのチェック
     if (!$created) {
         $after = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $data[$this->{$model}->alias]['id'])));
         $this->assertEquals($after, Hash::merge($before, array($this->{$model}->alias => array('is_latest' => false))));
     }
     //更新のチェック
     $actual = $this->_getActual($id, $created);
     $expected = $this->_getExpected($id, $data, $before, $created);
     $this->assertEquals($expected, $actual);
     return $actual;
 }
开发者ID:NetCommons3,项目名称:Workflow,代码行数:35,代码来源:WorkflowSaveTest.php

示例3: getRolesRoomsUsers

 /**
  * Return roles_rooms_users
  *
  * @param array $conditions Conditions by Model::find
  * @return array
  */
 public function getRolesRoomsUsers($conditions = array())
 {
     $this->Room = ClassRegistry::init('Rooms.Room');
     $conditions = Hash::merge(array('Room.page_id_top NOT' => null), $conditions);
     $rolesRoomsUsers = $this->find('all', array('recursive' => -1, 'fields' => array($this->alias . '.*', $this->RolesRoom->alias . '.*', $this->Room->alias . '.*'), 'joins' => array(array('table' => $this->RolesRoom->table, 'alias' => $this->RolesRoom->alias, 'type' => 'INNER', 'conditions' => array($this->alias . '.roles_room_id' . ' = ' . $this->RolesRoom->alias . ' .id')), array('table' => $this->Room->table, 'alias' => $this->Room->alias, 'type' => 'INNER', 'conditions' => array($this->RolesRoom->alias . '.room_id' . ' = ' . $this->Room->alias . ' .id'))), 'conditions' => $conditions));
     return $rolesRoomsUsers;
 }
开发者ID:Onasusweb,项目名称:Rooms,代码行数:13,代码来源:RolesRoomsUser.php

示例4: edit

 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if (!$this->initLink()) {
         return;
     }
     $this->Categories->initCategories(true);
     $this->Paginator->settings = array('Link' => array('order' => array('LinkOrder.weight' => 'asc'), 'conditions' => array('Link.block_id' => $this->viewVars['blockId'], 'Link.is_latest' => true), 'limit' => -1));
     $links = $this->Paginator->paginate('Link');
     $links = Hash::combine($links, '{n}.LinkOrder.weight', '{n}', '{n}.Category.id');
     //POST処理
     $data = array();
     if ($this->request->isPost()) {
         //登録処理
         $data = $this->data;
         $this->LinkOrder->saveLinkOrders($data);
         //validationError
         if ($this->NetCommons->handleValidationError($this->LinkOrder->validationErrors)) {
             //リダイレクト
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
     }
     $data = Hash::merge(array('links' => $links), $data);
     $results = $this->camelizeKeyRecursive($data);
     $this->set($results);
 }
开发者ID:Onasusweb,项目名称:Links,代码行数:31,代码来源:LinkOrdersController.php

示例5: checkboxPluginsRoom

 /**
  * Outputs room plugins
  *
  * @param string $roomId rooms.id
  * @param array $attributes The HTML attributes of the select element.
  * @return string Formatted CHECKBOX element
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
  */
 public function checkboxPluginsRoom($roomId, $attributes = array())
 {
     $html = '';
     //Modelの呼び出し
     $this->Plugin = ClassRegistry::init('PluginManager.Plugin');
     $this->PluginsRoom = ClassRegistry::init('PluginManager.PluginsRoom');
     //findのoptionsセット
     $findOptions = array('fields' => array($this->Plugin->alias . '.key', $this->Plugin->alias . '.name', $this->PluginsRoom->alias . '.room_id', $this->PluginsRoom->alias . '.plugin_key'), 'conditions' => array($this->Plugin->alias . '.type' => Plugin::PLUGIN_TYPE_FOR_FRAME, $this->Plugin->alias . '.language_id' => Configure::read('Config.languageId')), 'order' => array($this->Plugin->alias . '.weight' => 'asc'));
     //データ取得
     if (isset($attributes['all']) && $attributes['all']) {
         $plugins = $this->Plugin->find('all', Hash::merge($findOptions, array('recursive' => -1, 'joins' => array(array('table' => $this->PluginsRoom->table, 'alias' => $this->PluginsRoom->alias, 'type' => 'LEFT', 'conditions' => array($this->Plugin->alias . '.key' . ' = ' . $this->PluginsRoom->alias . ' .plugin_key', $this->PluginsRoom->alias . '.room_id' => $roomId))))));
         unset($attributes['all']);
     } else {
         $plugins = $this->PluginsRoom->find('all', Hash::merge($findOptions, array('recursive' => 0, 'conditions' => array($this->PluginsRoom->alias . '.room_id' => $roomId))));
     }
     //チェックボックスの設定
     $options = Hash::combine($plugins, '{n}.Plugin.key', '{n}.Plugin.name');
     $this->_View->request->data['Plugin']['key'] = array_keys($options);
     foreach (array_keys($this->_View->request->data['Plugin']['key']) as $index) {
         $html .= $this->Form->hidden('Plugin.' . $index . '.key');
     }
     $defaults = Hash::extract($plugins, '{n}.PluginsRoom[room_id=' . $roomId . ']');
     $defaults = array_values(Hash::combine($defaults, '{n}.plugin_key', '{n}.plugin_key'));
     $this->_View->request->data['PluginsRoom']['plugin_key'] = $defaults;
     $html .= $this->Form->select('PluginsRoom.plugin_key', $options, Hash::merge($attributes, array('multiple' => 'checkbox')));
     return $html;
 }
开发者ID:Onasusweb,项目名称:PluginManager,代码行数:35,代码来源:PluginsFormHelper.php

示例6: beforeValidate

 /**
  * beforeValidate is called before a model is validated, you can use this callback to
  * add behavior validation rules into a models validate array. Returning false
  * will allow you to make the validation fail.
  *
  * @param Model $model Model using this behavior
  * @param array $options Options passed from Model::save().
  * @return mixed False or null will abort the operation. Any other result will continue.
  * @see Model::save()
  */
 public function beforeValidate(Model $model, $options = array())
 {
     $model->loadModels(array('CircularNoticeContent' => 'CircularNotices.CircularNoticeContent', 'CircularNoticeTargetUser' => 'CircularNotices.CircularNoticeTargetUser', 'User' => 'Users.User'));
     if (!$model->data['CircularNoticeContent']['is_room_target']) {
         // 回覧先ユーザのバリデーション処理
         if (!isset($model->data['CircularNoticeTargetUser'])) {
             $model->data['CircularNoticeTargetUser'] = array();
         }
         $model->CircularNoticeTargetUser->set($model->data['CircularNoticeTargetUser']);
         // ユーザ選択チェック
         $targetUsers = Hash::extract($model->data['CircularNoticeTargetUser'], '{n}.user_id');
         if (!$model->CircularNoticeTargetUser->isUserSelected($targetUsers)) {
             $model->CircularNoticeTargetUser->validationErrors['user_id'] = sprintf(__d('circular_notices', 'Select user'));
             $model->validationErrors = Hash::merge($model->validationErrors, $model->CircularNoticeTargetUser->validationErrors);
             return false;
         }
         if (!$model->CircularNoticeTargetUser->validates()) {
             $model->validationErrors = Hash::merge($model->validationErrors, $model->CircularNoticeTargetUser->validationErrors);
             return false;
         }
         if (!$model->User->existsUser($targetUsers)) {
             $model->CircularNoticeTargetUser->validationErrors['user_id'][] = sprintf(__d('net_commons', 'Failed on validation errors. Please check the input data.'));
             $model->validationErrors = Hash::merge($model->validationErrors, $model->CircularNoticeTargetUser->validationErrors);
             return false;
         }
     }
     return true;
 }
开发者ID:go-to,项目名称:CircularNotices,代码行数:38,代码来源:CircularNoticeTargetUserBehavior.php

示例7: __construct

 /**
  * Constructor
  *
  * @param ComponentCollection $collection A ComponentCollection for this component
  * @param array $settings Array of settings.
  * @return RememberMeComponent
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     parent::__construct($collection, $settings);
     $this->_checkAndSetCookieLifeTime();
     $this->settings = Hash::merge($this->_defaults, $settings);
     $this->configureCookie($this->settings['cookie']);
 }
开发者ID:harpax,项目名称:users,代码行数:14,代码来源:RememberMeComponent.php

示例8: beforeFind

 /**
  * beforeFind can be used to cancel find operations, or modify the query that will be executed.
  * By returning null/false you can abort a find. By returning an array you can modify/replace the query
  * that is going to be run.
  *
  * @param Model $model Model using this behavior
  * @param array $query Data used to execute this query, i.e. conditions, order, etc.
  * @return bool|array False or null will abort the operation. You can return an array to replace the
  *   $query that will be eventually run.
  */
 public function beforeFind(Model $model, $query)
 {
     $model->Like = ClassRegistry::init('Likes.Like');
     $model->LikesUser = ClassRegistry::init('Likes.LikesUser');
     $conditions = $query['conditions'];
     if (is_array($query['conditions']) === false) {
         return $query;
     }
     $columns = array();
     if (!isset($query['fields'])) {
         $columns = 'Like.*';
     } else {
         $columns = $query['fields'];
     }
     $columns = Hash::merge((array) $columns, array_keys($conditions));
     // Like条件あったらJOIN
     if (!preg_grep('/^Like\\./', $columns) && !preg_grep('/^LikesUser\\./', $columns)) {
         return $query;
     }
     if (!isset($query['fields'])) {
         $query['fields'] = '*';
     }
     $query['joins'][] = array('table' => $model->Like->table, 'alias' => $model->Like->alias, 'type' => 'LEFT', 'conditions' => array('Like.plugin_key' => Inflector::underscore($model->plugin), $this->__model . '.' . $this->__field . ' = ' . 'Like.content_key'));
     $likesUserConditions = array('Like.id = LikesUser.like_id');
     if (Current::read('User.id')) {
         $likesUserConditions['LikesUser.user_id'] = Current::read('User.id');
     } else {
         $likesUserConditions['LikesUser.session_key'] = CakeSession::id();
     }
     $query['joins'][] = array('table' => $model->LikesUser->table, 'alias' => $model->LikesUser->alias, 'type' => 'LEFT', 'conditions' => $likesUserConditions);
     return $query;
 }
开发者ID:Onasusweb,项目名称:Likes,代码行数:42,代码来源:LikeBehavior.php

示例9: afterFind

 /**
  * After find callback. Can be used to modify any results returned by find.
  *
  * @param Model   $model   Model using this behavior
  * @param mixed   $results The results of the find operation
  * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
  *
  * @return mixed An array value will replace the value of $results - any other value will be ignored.
  */
 public function afterFind(Model $model, $results, $primary = false)
 {
     parent::afterFind($model, $results, $primary);
     if ($primary && array_key_exists($model->alias, $results[0])) {
         $arrObj = new ArrayObject($results);
         $iterator = $arrObj->getIterator();
         while ($iterator->valid()) {
             $result = [];
             if (isset($iterator->current()[$model->alias]) && count($iterator->current()[$model->alias]) > 0) {
                 $key = "{$model->alias}.{$this->settings[$model->alias]['key']}";
                 $value = "{$model->alias}.{$this->settings[$model->alias]['value']}";
                 $result = Hash::combine($iterator->current(), $key, $value);
             }
             if (!array_key_exists($this->settings[$model->alias]['key'], $iterator->current()[$model->alias]) && !array_key_exists($this->settings[$model->alias]['value'], $iterator->current()[$model->alias])) {
                 $results[$iterator->key()][$model->alias] = Hash::merge($iterator->current()[$model->alias], $result);
             } else {
                 $results[$iterator->key()][$model->alias] = $result;
             }
             $iterator->next();
         }
     } elseif (array_key_exists($model->alias, $results)) {
         $key = "{n}.{$model->alias}.{$this->settings[$model->alias]['key']}";
         $value = "{n}.{$model->alias}.{$this->settings[$model->alias]['value']}";
         $output = Hash::combine($results, $key, $value);
         $results[$model->alias] = $output;
     }
     return $results;
 }
开发者ID:hurad,项目名称:hurad,代码行数:37,代码来源:KeyValueStorageBehavior.php

示例10: beforeValidate

 /**
  * Called during validation operations, before validation. Please note that custom
  * validation rules can be defined in $validate.
  *
  * @param array $options Options passed from Model::save().
  * @return bool True if validate operation should continue, false to abort
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
  * @see Model::save()
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function beforeValidate($options = array())
 {
     // ウィザード画面中はstatusチェックをしないでほしいので
     // ここに来る前にWorkflowBehaviorでつけられたstatus-validateを削除しておく
     if (Hash::check($options, 'validate') == RegistrationsComponent::REGISTRATION_VALIDATE_TYPE) {
         $this->validate = Hash::remove($this->validate, 'status');
     }
     $this->validate = Hash::merge($this->validate, array('block_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'on' => 'update')), 'title' => array('rule' => 'notBlank', 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('registrations', 'Title')), 'required' => true, 'allowEmpty' => false), 'answer_timing' => array('publicTypeCheck' => array('rule' => array('inList', array(RegistrationsComponent::USES_USE, RegistrationsComponent::USES_NOT_USE)), 'message' => __d('net_commons', 'Invalid request.')), 'requireOtherFields' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.answer_start_period', 'Registration.answer_end_period'), 'OR'), 'message' => __d('registrations', 'if you set the period, please set time.'))), 'answer_start_period' => array('checkDateTime' => array('rule' => 'checkDateTime', 'message' => __d('registrations', 'Invalid datetime format.'))), 'answer_end_period' => array('checkDateTime' => array('rule' => 'checkDateTime', 'message' => __d('registrations', 'Invalid datetime format.')), 'checkDateComp' => array('rule' => array('checkDateComp', '>=', 'answer_start_period'), 'message' => __d('registrations', 'start period must be smaller than end period'))), 'is_key_pass_use' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.')), 'requireOtherFieldsKey' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('AuthorizationKey.authorization_key'), 'AND'), 'message' => __d('registrations', 'if you set the use key phrase period, please set key phrase text.')), 'authentication' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.is_image_authentication'), 'XOR'), 'message' => __d('registrations', 'Authentication key setting , image authentication , either only one can not be selected.'))), 'is_image_authentication' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.')), 'authentication' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.is_key_pass_use'), 'XOR'), 'message' => __d('registrations', 'Authentication key setting , image authentication , either only one can not be selected.'))), 'is_answer_mail_send' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_regist_user_send' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'reply_to' => array('email' => array('rule' => array('email', false, null), 'message' => sprintf(__d('mails', '%s, please enter by e-mail format'), __d('mails', 'E-mail address to receive a reply')), 'allowEmpty' => true))));
     parent::beforeValidate($options);
     // 最低でも1ページは存在しないとエラー
     if (!isset($this->data['RegistrationPage'][0])) {
         $this->validationErrors['pickup_error'] = __d('registrations', 'please set at least one page.');
     } else {
         // ページデータが存在する場合
         // 配下のページについてバリデート
         $validationErrors = array();
         $maxPageIndex = count($this->data['RegistrationPage']);
         $options['maxPageIndex'] = $maxPageIndex;
         foreach ($this->data['RegistrationPage'] as $pageIndex => $page) {
             // それぞれのページのフィールド確認
             $this->RegistrationPage->create();
             $this->RegistrationPage->set($page);
             // ページシーケンス番号の正当性を確認するため、現在の配列インデックスを渡す
             $options['pageIndex'] = $pageIndex;
             if (!$this->RegistrationPage->validates($options)) {
                 $validationErrors['RegistrationPage'][$pageIndex] = $this->RegistrationPage->validationErrors;
             }
         }
         $this->validationErrors += $validationErrors;
     }
     // 引き続き登録フォーム本体のバリデートを実施してもらうためtrueを返す
     return true;
 }
开发者ID:NetCommons3,项目名称:Registrations,代码行数:43,代码来源:Registration.php

示例11: blocks

 public function blocks($position_name, $options = array())
 {
     $output = '';
     if ($this->is_empty($position_name)) {
         return $output;
     }
     $options = Hash::merge(array('element_options' => array()), $options);
     $element_options = $options['element_options'];
     $default_element = 'Blocks.block';
     $view = $this->_View;
     $view->Blocks->set('test', 'test 123');
     $blocks = $view->viewVars['blocks_for_layout'][$position_name];
     foreach ($blocks as $idx => $block) {
         $block['id'] = $idx;
         $element = $block['element'];
         $exists = $view->elementExists($element);
         $block_output = '';
         if ($exists) {
             $block_output = $view->element($element, compact('block'), $element_options);
         } else {
             if (!empty($element)) {
                 $this->log(sprintf('Missing element `%s`', $block['element']), LOG_WARNING);
             }
             $block_output = $view->element($default_element, compact('block'), array('ignoreMissing' => true) + $element_options);
         }
         $output .= $block_output;
     }
     return $output;
 }
开发者ID:pdkhuong,项目名称:BBG,代码行数:29,代码来源:PositionsHelper.php

示例12: nestedLinks

 /**
  * Generate tree menu
  *
  * @return void
  **/
 public function nestedLinks($links, $options, $depth = 0)
 {
     $defaults = array('mainClass' => 'nav nav-pills', 'mainRole' => 'menulist', 'subClass' => 'dropdown-menu', 'subRole' => 'menu');
     $options = Hash::merge($defaults, $options);
     $items = '';
     foreach ($links as $link) {
         $hasChildren = !empty($link['children']);
         if (strstr($link['Link']['link'], 'controller:')) {
             $link['Link']['link'] = $this->Menus->linkStringToArray($link['Link']['link']);
         }
         $content = $this->Html->link($link['Link']['title'], $link['Link']['link'], array('class' => ($hasChildren ? ' dropdown-toggle' : '') . $link['Link']['class'] . '-link', 'data-toggle' => $hasChildren ? 'dropdown' : '', 'data-target' => '#', 'target' => $link['Link']['target'], 'rel' => $link['Link']['rel'], 'title' => empty($link['Link']['description']) ? $link['Link']['title'] : $link['Link']['description']));
         if ($hasChildren) {
             $content .= $this->nestedLinks($link['children'], $options, $depth + 1);
         }
         $liClass = array($hasChildren ? 'dropdown' : 'no-children', $link['Link']['class']);
         if (!empty($this->_View->request->params['locale'])) {
             $currentUrl = substr($this->_View->request->url, strlen($this->_View->request->params['locale'] . '/'));
         } else {
             $currentUrl = $this->_View->request->url;
         }
         if (Router::url($link['Link']['link']) == Router::url('/' . $currentUrl)) {
             $liClass[] = 'active';
         }
         $items .= $this->Html->tag('li', $content, array('class' => implode(' ', $liClass), 'id' => 'link-' . $link['Link']['id']));
     }
     $attrs = array('class' => $depth == 0 ? $options['mainClass'] : $options['subClass'], 'role' => $depth == 0 ? $options['mainRole'] : $options['subRole']);
     return $this->Html->tag($options['tag'], $items, $attrs);
 }
开发者ID:elcuro,项目名称:bootstrapnav,代码行数:33,代码来源:BootstrapNavHelper.php

示例13: edit

 /**
  * edit
  *
  * @param int $roomId rooms.id
  * @return void
  */
 public function edit($roomId = null)
 {
     //登録処理の場合、URLよりPOSTパラメータでチェックする
     if ($this->request->isPost()) {
         $roomId = $this->data['Room']['id'];
     }
     //ルームデータチェック&セット
     if (!$this->RoomsUtility->validRoom($roomId, Configure::read('Config.languageId'))) {
         return;
     }
     //スペースデータチェック&セット
     if (!$this->SpacesUtility->validSpace($this->viewVars['room']['Room']['space_id'])) {
         return;
     }
     if ($this->request->isPost()) {
         //登録処理
         $data = $this->data;
         //--不要パラメータ除去
         unset($data['save']);
         $this->request->data = $data;
     } else {
         $results = $this->UserSearch->search();
         $this->set('users', $results);
         $displayFields = Hash::merge(array('room_role_key'), $this->User->dispayFields($this->params['plugin'] . '/' . $this->params['controller']));
         $this->set('displayFields', $displayFields);
     }
 }
开发者ID:Onasusweb,项目名称:Rooms,代码行数:33,代码来源:RoomsRolesUsersController.php

示例14: payment

 public function payment()
 {
     $this->request->allowMethod('post');
     if (!isset($this->request->data['amount']) || empty($this->request->data['amount'])) {
         $this->redirect($this->referer());
     }
     $firstName = $lastName = '';
     $name = explode(' ', $this->currUser['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $this->currUser['User']['username'], 'phone' => $this->currUser['User']['phone']);
     try {
         $customer = Braintree_Customer::find('konstruktor-' . $this->currUser['User']['id']);
         $customer = Braintree_Customer::update('konstruktor-' . $this->currUser['User']['id'], $customerData);
     } catch (Exception $e) {
         $customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $this->currUser['User']['id']), $customerData));
     }
     if ($customer->success) {
         $customer = $customer->customer;
     } else {
         throw new NotFoundException(__d('billing', 'Invalid billing group'));
     }
     $this->Session->write('Billing', array('amount' => $this->request->data['amount']));
     $this->layout = 'profile_new';
     $clientToken = Braintree_ClientToken::generate();
     $this->set('clientToken', $clientToken);
     $this->set('customer', $customer);
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:30,代码来源:BillingUserController.php

示例15: setup

 public function setup(Model $model, $config = array())
 {
     $this->config = Hash::merge(self::$defaultConfig, (array) $config);
     if (!$model->schema($this->config['field'])) {
         throw new BadFunctionCallException(__d('optimistic_lock', 'Model %s doesn\'t have field %s.', $model->alias, $this->config['field']));
     }
 }
开发者ID:tad80,项目名称:optimisticlock,代码行数:7,代码来源:OptimisticLockBehavior.php


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