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


PHP Hash::extract方法代码示例

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


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

示例1: afterFind

 public function afterFind($results, $primary = false)
 {
     if (!empty($results)) {
         $braintreePlans = Braintree_Plan::all();
         foreach ($results as $resultKey => $result) {
             if (isset($result['BillingPlan']) && !empty($result['BillingPlan'])) {
                 foreach ($result['BillingPlan'] as $key => $plan) {
                     $_arr = array();
                     $_arr[0]['BillingPlan'] = $plan;
                     $_arr = Hash::extract($this->BillingPlan->decodeItems($_arr), "0.BillingPlan");
                     foreach ($_arr['remote_plans'] as $remotePlan) {
                         foreach ($braintreePlans as $braintreePlan) {
                             if ($remotePlan == $braintreePlan->id) {
                                 $_arr['BraintreePlan'][] = $braintreePlan;
                             }
                         }
                     }
                     $result['BillingPlan'][$key] = $_arr;
                 }
             }
             $results[$resultKey] = $result;
         }
     }
     return $results;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:25,代码来源:BillingGroup.php

示例2: subsections

 public function subsections($mark_id, $model_id, $type_id)
 {
     $aCatalog = Hash::combine($this->TechDocApi->getMarks(), '{n}.id', '{n}');
     $mark = $aCatalog[$mark_id];
     $this->set('mark', $mark);
     unset($aCatalog);
     $aModels = Hash::combine($this->TechDocApi->getModels($mark_id), '{n}.id', '{n}');
     $model = $aModels[$model_id];
     $this->set('model', $model);
     unset($aModels);
     $aSubModels = Hash::combine($this->TechDocApi->getModelSections($mark_id, $model_id), '{n}.id', '{n}');
     $submodel = $aSubModels[$type_id];
     $this->set('submodel', $aSubModels[$type_id]);
     unset($aSubModels);
     $aSubsections = $this->TechDocApi->getModelSubsections($mark_id, $model_id, $type_id);
     $this->set('aSubsections', $aSubsections);
     $title = $mark['title'] . ' ' . $model['title'] . ' ' . $submodel['type'] . ' ' . $model['date_issue'];
     $this->seo = array('title' => $title, 'keywords' => "Каталог запчастей для {$title}, запчасти для {$title}", 'descr' => "На нашем сайте вы можете приобрести лучшие запчасти {$title} в Белорусии. Низкие цены на запчасти, быстрая доставка по стране, диагностика, ремонт.");
     // Сохраняем осн.узлы для того, чтобы навесить картинки
     $this->loadModel('Subsection');
     $this->Subsection->saveMainSubsections($aSubsections);
     // получаем список узлов с картинками
     $ids = Hash::extract($aSubsections, '{n}.id');
     $conditions = array('Subsection.td_id' => $ids, 'Media.main' => 1);
     $order = 'Subsection.td_id';
     $subsections = $this->Subsection->find('all', compact('conditions', 'order'));
     $this->set('subsections', $subsections);
 }
开发者ID:Mirocow,项目名称:gpz,代码行数:28,代码来源:TechdocController.php

示例3: beforeRender

 /**
  * beforeRender
  *
  * @param Controller $controller Controller
  * @return void
  * @throws NotFoundException
  */
 public function beforeRender(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested']) || $controller->request->is('ajax')) {
         return;
     }
     //Pluginデータ取得
     $controller->Plugin = ClassRegistry::init('PluginManager.Plugin', true);
     $controller->PluginsRole = ClassRegistry::init('PluginManager.PluginsRole', true);
     $controlPanel = $controller->Plugin->create(array('key' => 'control_panel', 'name' => __d('control_panel', 'Control Panel Top'), 'default_action' => 'control_panel/index'));
     $this->plugins = $controller->PluginsRole->getPlugins(array(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, Plugin::PLUGIN_TYPE_FOR_SYSTEM_MANGER), Current::read('User.role_key'), 'INNER');
     array_unshift($this->plugins, $controlPanel);
     //Layoutのセット
     $controller->layout = 'ControlPanel.default';
     //cancelUrlをセット
     $controller->set('cancelUrl', '/');
     $controller->set('isControlPanel', true);
     $controller->set('hasControlPanel', true);
     //ページHelperにセット
     $controller->set('pluginsMenu', $this->plugins);
     if (isset($this->settings['plugin'])) {
         $plugin = $this->settings['plugin'];
     } else {
         $plugin = $controller->params['plugin'];
     }
     $plugin = Hash::extract($this->plugins, '{n}.Plugin[key=' . $plugin . ']');
     if (isset($plugin[0]['name'])) {
         if (!isset($controller->viewVars['title'])) {
             $controller->set('title', $plugin[0]['name']);
         }
         $controller->set('pageTitle', $plugin[0]['name']);
     }
 }
开发者ID:s-nakajima,项目名称:ControlPanel,代码行数:40,代码来源:ControlPanelLayoutComponent.php

示例4: 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

示例5: enablePromotions

 /**
  * Attach promo Adjustment
  * @see PromoAdjustmentBehavior
  * @param $controller
  */
 protected function enablePromotions($controller)
 {
     if (in_array($controller->request->params['action'], $this->cartActions)) {
         if (isset($controller->ShoppingCartItem)) {
             App::import('Model', 'PromotionalProduct');
             App::import('Model', 'SystemSetting');
             /**
              * Get Promos
              */
             $this->promos = $this->loadPromos();
             // Load without cache
             $settings = ['promos' => [], 'className' => 'PromoItems'];
             foreach ($this->promos as $promo) {
                 /**
                  * Setup settings for Promo
                  */
                 $settings['promos'][] = ['id' => $promo['PromotionalProduct']['id'], 'qualifying_sku' => Hash::extract($promo, 'QualifyingProduct.{n}.sku'), 'reward_sku' => $promo['PromotionalProduct']['reward_sku'], 'reward_type' => $promo['PromotionalProduct']['promotional_product_type_id'], 'qty' => $promo['PromotionalProduct']['qty']];
             }
             /**
              * Load Promo
              */
             if (empty($controller->request->data['market_id'])) {
                 $settings['market_id'] = $controller->Session->read('market_id');
             } else {
                 $settings['market_id'] = $controller->request->data['market_id'];
             }
             $controller->ShoppingCartItem->Behaviors->load('PromoItems', $settings);
         }
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:35,代码来源:PromotionalComponent.php

示例6: render

 public function render($form, $values, $offset = 0)
 {
     $html = '';
     $_values = array();
     if ($values) {
         $_values = array_combine(Hash::extract($values, '{n}.PMFormValue.field_id'), Hash::extract($values, '{n}.PMFormValue.value'));
     }
     $_ids = array();
     if ($values) {
         $_ids = array_combine(Hash::extract($values, '{n}.PMFormValue.field_id'), Hash::extract($values, '{n}.PMFormValue.id'));
     }
     foreach ($form as $i => $row) {
         $field = $row['FormField'];
         $value = Hash::get($_values, $field['id']);
         /*
         if ($field['id'] == 6) {
         	fdebug($field);
         	fdebug(array_merge(
         		$this->_options($i, 'value'), $this->_inputOptions($field), array('value' => $value)
         	));
         }
         */
         $html .= $this->_renderInput($field, $value, $i + $offset);
         if (isset($_values[$field['id']])) {
             $html .= $this->PHForm->hidden('PMFormValue.id', array_merge($this->_options($i + $offset, 'id'), array('value' => Hash::get($_ids, $field['id']))));
         }
         $html .= $this->PHForm->hidden('PMFormValue.field_id', array_merge($this->_options($i + $offset, 'field_id'), array('value' => $field['id'])));
     }
     return $html;
 }
开发者ID:Mirocow,项目名称:gpz,代码行数:30,代码来源:PHFormFieldsHelper.php

示例7: index

 public function index($parent_id = '')
 {
     // Process filter
     if ($user_id = $this->request->query('user_id')) {
         $this->paginate['conditions']['user_id'] = $user_id;
     }
     $status = $this->request->query('status');
     if ($status != '') {
         $this->paginate['conditions']['status'] = $status;
     }
     $id = $this->request->query('id');
     if ($id) {
         if (strpos($id, ',') !== false) {
             $id = explode(',', $id);
         }
         $this->paginate['conditions']['id'] = $id;
     }
     $rowset = parent::index();
     $ids = Hash::extract($rowset, '{n}.Order.id');
     $orders = $this->Order->getOrder($ids);
     $ids = Hash::extract($rowset, '{n}.Order.user_id');
     $users = Hash::combine($this->User->findAllById($ids), '{n}.User.id', '{n}.User');
     $aUserOptions = $this->User->find('list', array('fields' => array('id', 'username')));
     $this->set(compact('orders', 'users', 'aUserOptions'));
 }
开发者ID:Fyr,项目名称:yday,代码行数:25,代码来源:AdminOrdersController.php

示例8: milestones

 /**
  * http://developers.facebook.com/docs/reference/api/page/#lifeevents
  **/
 public function milestones($pageId, $options = array())
 {
     $request = array();
     $limit = 15;
     if ($options) {
         $request['uri']['query'] = $options;
     }
     if (isset($options['limit'])) {
         $limit = $options['limit'];
     }
     $trace = debug_backtrace();
     $data = $this->_request(sprintf('/%s/%s', $pageId, $trace[0]['function']), $request);
     $results = array();
     $count = 0;
     foreach ($data['data'] as $k => $val) {
         $results['data'][$k] = $val;
         $photos = $this->milestonePhotos($val['id']);
         $results['data'][$k]['photos'] = Hash::extract($photos['data'], '{n}.source');
         $count++;
         if ($count == $limit) {
             break;
         }
     }
     return $results;
 }
开发者ID:adderall,项目名称:CakePHP-Facebook-API-Plugin,代码行数:28,代码来源:FacebookPage.php

示例9: userFilters

 /**
  * Filter Audits by user id of model
  * @param $conditions
  */
 private function userFilters(&$conditions)
 {
     $model = $this->request->query['model'];
     $user_id = $this->request->query['user_id'];
     $entity_ids = null;
     if (!empty($user_id) && !empty($model)) {
         switch ($model) {
             case 'UserOauth2':
                 $entity_ids = $this->UserOauth2->find('all', ['fields' => 'id', 'conditions' => ['user_id' => $user_id]]);
                 break;
             case 'Email':
                 $entity_ids = $this->Email->find('all', ['fields' => 'id', 'conditions' => ['user_id' => $user_id]]);
                 break;
             case 'Address':
                 $entity_ids = $this->Address->find('all', ['fields' => 'id', 'conditions' => ['user_id' => $user_id]]);
                 break;
             default:
                 break;
         }
         if (!empty($entity_ids)) {
             $entity_ids = Hash::extract($entity_ids, "{n}.{$model}.id");
             $conditions["Audit.entity_id"] = $entity_ids;
         }
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:29,代码来源:AuditController.php

示例10: edit

 /**
  * edit
  *
  * @param string $roleKey user_roles.key
  * @return void
  */
 public function edit($roleKey = null)
 {
     if ($this->request->isPut()) {
         //不要パラメータ除去
         $data = $this->data;
         unset($data['save']);
         //登録処理
         if ($this->UserRoleSetting->saveUserRoleSetting($data)) {
             //正常の場合
             $this->redirect('/user_roles/user_roles/index/');
             return;
         }
         $this->NetCommons->handleValidationError($this->UserRoleSetting->validationErrors);
         $this->request->data = $data;
     } else {
         $this->request->data = $this->UserRoleSetting->find('first', array('recursive' => -1, 'conditions' => array('role_key' => $roleKey)));
         $this->request->data['UserRoleSetting']['is_usable_room_manager'] = (bool) $this->PluginsRole->find('count', array('recursive' => -1, 'conditions' => array('role_key' => $roleKey, 'plugin_key' => 'rooms')));
     }
     //既存データ取得
     $userRole = $this->UserRole->find('first', array('recursive' => -1, 'conditions' => array('type' => UserRole::ROLE_TYPE_USER, 'key' => $roleKey, 'language_id' => Configure::read('Config.languageId'))));
     $this->request->data = Hash::merge($userRole, $this->request->data);
     if ($plugin = Hash::extract($this->ControlPanelLayout->plugins, '{n}.Plugin[key=rooms]')) {
         $this->set('roomsPluginName', $plugin[0]['name']);
     } else {
         $this->set('roomsPluginName', __d('user_roles', 'Room manager'));
     }
     $this->set('roleKey', $roleKey);
     $this->set('subtitle', $this->request->data['UserRole']['name']);
 }
开发者ID:Onasusweb,项目名称:UserRoles,代码行数:35,代码来源:UserRoleSettingsController.php

示例11: profileCommand

 /**
  * Profile command
  * 
  * @param string $command
  * @return array
  */
 public function profileCommand($command)
 {
     $tasks = $this->Task->find('all', array('conditions' => array('command' => $command, 'status' => array(TaskType::STOPPED, TaskType::FINISHED), 'runtime >' => 0), 'fields' => array('runtime', 'id', 'started', 'stopped', 'created', 'waittime'), 'limit' => Configure::read('Task.profilerLimit'), 'order' => array('id' => 'DESC')));
     if (!$tasks) {
         return null;
     }
     $statistics = array_map(function ($item) {
         $endDate = new DateTime($item['stopped']);
         $startDate = new DateTime($item['started']);
         $createdDate = new DateTime($item['created']);
         $item['runtimeHuman'] = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat'));
         $item['waittimeHuman'] = $createdDate->diff($startDate)->format(Configure::read('Task.dateDiffFormat'));
         $item['startedTimestamp'] = $startDate->getTimestamp();
         $item['runtime'] = (int) $item['runtime'];
         $item['waittime'] = (int) $item['waittime'];
         return $item;
     }, Hash::extract($tasks, '{n}.{s}'));
     $runtimes = Hash::extract($statistics, '{n}.runtime');
     $runtimeAverage = (int) round($runtimes ? array_sum($runtimes) / count($runtimes) : 0);
     $runtimeMax = $runtimes ? max($runtimes) : 0;
     $runtimeMin = $runtimes ? min($runtimes) : 0;
     $waittimes = Hash::extract($statistics, '{n}.waittime');
     $waittimeAverage = (int) round($waittimes ? array_sum($waittimes) / count($waittimes) : 0);
     $waittimeMax = $waittimes ? max($waittimes) : 0;
     $waittimeMin = $waittimes ? min($waittimes) : 0;
     $countByStatus = array();
     foreach (TaskType::getTypes() as $statusCode) {
         $countByStatus[$statusCode] = $this->Task->find('count', array('conditions' => array('command' => $command, 'status' => $statusCode)));
     }
     $errored = $this->Task->find('count', array('conditions' => array('command' => $command, 'errored' => true)));
     return array('command' => $command, 'countByStatus' => $countByStatus, 'errored' => $errored, 'statistics' => $statistics, 'runtimeAverage' => $runtimeAverage, 'runtimeAverageHuman' => $this->_secondsToHuman($runtimeAverage), 'runtimeMax' => $runtimeMax, 'runtimeMaxHuman' => $this->_secondsToHuman($runtimeMax), 'runtimeMin' => $runtimeMin, 'runtimeMinHuman' => $this->_secondsToHuman($runtimeMin), 'waittimeAverage' => $waittimeAverage, 'waittimeAverageHuman' => $this->_secondsToHuman($waittimeAverage), 'waittimeMax' => $waittimeMax, 'waittimeMaxHuman' => $this->_secondsToHuman($waittimeMax), 'waittimeMin' => $waittimeMin, 'waittimeMinHuman' => $this->_secondsToHuman($waittimeMin));
 }
开发者ID:imsamurai,项目名称:cakephp-task-plugin,代码行数:38,代码来源:TaskProfiler.php

示例12: testAfterFind

 public function testAfterFind()
 {
     $result = $this->User->find('first');
     $this->assertTrue(!array_key_exists('password', $result[$this->User->alias]));
     $result = $this->User->find('all');
     $this->assertEmpty(Hash::extract($result, '{n}.' . $this->User->alias . '.password'));
 }
开发者ID:gourmet,项目名称:common,代码行数:7,代码来源:FilterableBehaviorTest.php

示例13: block

 public function block()
 {
     try {
         $order_id = $this->request->data('order_id');
         if (!$order_id) {
             throw new Exception(__('Incorrect request'));
         }
         $products = $this->request->data('products');
         if ($products && !is_array($products)) {
             throw new Exception(__('Incorrect request'));
         }
         $blocked = $this->request->data('blocked');
         if ($products) {
             foreach ($products as $product_id) {
                 $this->OrderProduct->updateAll(compact('blocked'), compact('order_id', 'product_id'));
             }
         }
         $products = $this->OrderProduct->getByTypes($order_id, false);
         $distributed = $this->OrderProduct->getByTypes($order_id, true);
         $aID = Hash::extract($distributed, '{n}.{n}.OrderProduct.user_id');
         $users = $this->User->getUsers($aID);
         $this->setResponse(compact('products', 'distributed', 'users'));
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:26,代码来源:DeviceAjaxController.php

示例14: 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

示例15: mirror

 /**
  * mirror action
  *
  * @param null $slug
  *
  * @throws NotFoundException
  * @return void
  */
 function mirror($slug = null)
 {
     $this->PluginsState->recursive = -1;
     $cloning_count = $this->PluginsState->find('count', array('conditions' => array('PluginsState.ip_address' => $this->request->clientIp(false))));
     if ($cloning_count >= Configure::read('App.max_cloning_per_ip')) {
         $this->Session->setFlash(__('You have reached the maximum of %s plugins queued for cloning currently, please try again later.', Configure::read('App.max_cloning_per_ip')), 'alert-warning', array('close' => true));
         $this->redirect($this->referer());
     }
     $plugin = $this->Plugin->find('first', array('contain' => array('PluginsState' => array('State')), 'conditions' => array('slug' => $slug)));
     // Some basic sanity checks...
     if (!$plugin) {
         throw new NotFoundException(__('Invalid plugin'));
     }
     if (in_array('cloned', Hash::extract($plugin, 'PluginsState.{n}.State.name'))) {
         $this->Session->setFlash(__('This plugin has already been cloned.'), 'alert-error', array('close' => true));
         $this->redirect($this->referer());
     }
     if (in_array('cloning', Hash::extract($plugin, 'PluginsState.{n}.State.name'))) {
         $this->Session->setFlash(__('This plugin is already in the cloning queue.'), 'alert-error', array('close' => true));
         $this->redirect($this->referer());
     }
     if ($this->PluginsState->findOrCreate($plugin['Plugin']['id'], 'cloning', $this->request->clientIp(false))) {
         $this->Session->setFlash(__('Plugin has been added to the queue to be cloned.'), 'alert-success', array('close' => true));
         $this->redirect($this->referer());
     }
     $this->Session->setFlash(__('There was a problem adding the plugin to the cloning queue.'), 'alert-error', array('close' => true));
     $this->redirect($this->referer());
 }
开发者ID:hasannawaz,项目名称:pluginmirror,代码行数:36,代码来源:PluginsController.php


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