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


PHP Controller::set方法代码示例

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


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

示例1: test_set

 public function test_set()
 {
     $controller = new Controller('');
     $controller->set('foo', 100);
     $controller->set('bar', array(1, 2));
     $this->assertEquals(100, $controller->view->vars['foo']);
     $this->assertEquals(array(1, 2), $controller->view->vars['bar']);
     $controller->set(array('foo' => 200));
     $this->assertEquals(200, $controller->view->vars['foo']);
 }
开发者ID:YoshinoriKato,项目名称:dietcake,代码行数:10,代码来源:controller_test.php

示例2: setGroupList

 /**
  * グループ一覧・グループユーザを設定
  *
  * @param Controller $controller コントローラー
  * @param array $query find条件
  * @return void
  */
 public function setGroupList(Controller $controller, $query = array())
 {
     $groups = $controller->Group->getGroupList($query);
     $controller->set('groups', $groups);
     $userIdArr = Hash::extract($groups, '{n}.GroupsUser.{n}.user_id');
     $userIdArr = array_unique($userIdArr);
     // 重複した値をまとめる
     $groupUsers = $controller->GroupsUser->getGroupUsers($userIdArr);
     $controller->set('users', $groupUsers);
 }
开发者ID:s-nakajima,项目名称:Groups,代码行数:17,代码来源:GroupsComponent.php

示例3: lookup

 /**
  * List users with filter capability as defined in User::$filterArgs
  *
  * This will be useful for ajax autocompletion
  */
 public function lookup(Controller $controller)
 {
     $request = $controller->request;
     $controller->Prg->commonProcess();
     $controller->User->Behaviors->attach('Users.UserApiResultFormatter');
     $controller->paginate = array('fields' => array('id', 'username', 'name', 'website', 'image', 'bio', 'timezone', 'status', 'created', 'updated'), 'contain' => array('Role' => array('fields' => array('id', 'title', 'alias'))), 'conditions' => $controller->User->parseCriteria($request->query));
     $users = $controller->paginate();
     $controller->set('_rootNode', 'users');
     $controller->set('user', $users);
     $controller->set('_serialize', 'user');
 }
开发者ID:saydulk,项目名称:croogo,代码行数:16,代码来源:UserApiComponent.php

示例4: startup

 /**
  * Called after the Controller::beforeFilter() and before the controller action
  *
  * @param Controller $controller Controller with components to startup
  * @return void
  * @link http://book.cakephp.org/2.0/ja/controllers/components.html#Component::startup
  */
 public function startup(Controller $controller)
 {
     $permissions = $controller->Workflow->getBlockRolePermissions($this->permission);
     $controller->set('permissions', $permissions);
     $controller->set('roles', $controller->viewVars['permissions']['Roles']);
     if ($controller->request->is('get')) {
         /** @see MailSetting::getMailSettingPlugin() */
         $mailSettingPlugin = $controller->MailSetting->getMailSettingPlugin(null, $this->typeKeys);
         $controller->set('mailSettingPlugin', $mailSettingPlugin);
     }
 }
开发者ID:NetCommons3,项目名称:Mails,代码行数:18,代码来源:MailSettingsComponent.php

示例5: error

 function error($message)
 {
     if (!headers_sent()) {
         header("HTTP/1.0 404 Not Found");
     }
     $controller = new Controller($this->request);
     $controller->getMenu = $controller->renderMenu('menu');
     $controller->set('content_for_menu', $controller->getMenu);
     $controller->set('message', $message);
     $controller->render('/errors/404');
 }
开发者ID:Nicolas97220,项目名称:kitjambon,代码行数:11,代码来源:dispatcher.php

示例6: lookup

 /**
  * List nodes with filter capability as defined in Node::$filterArgs
  *
  * This will be useful for ajax autocompletion
  */
 public function lookup(Controller $controller)
 {
     $request = $controller->request;
     $controller->Prg->commonProcess();
     $Node = $controller->{$controller->modelClass};
     $Node->Behaviors->attach('Nodes.NodeApiResultFormatter');
     $controller->paginate = array('fields' => array('id', 'parent_id', 'type', 'user_id', 'title', 'slug', 'body', 'excerpt', 'status', 'promote', 'path', 'terms', 'created', 'updated', 'publish_start', 'publish_end'), 'contain' => array('User', 'Meta', 'Taxonomy'), 'conditions' => $Node->parseCriteria($request->query));
     $nodes = $controller->paginate();
     $controller->set('_rootNode', 'nodes');
     $controller->set('node', $nodes);
     $controller->set('_serialize', 'node');
 }
开发者ID:saydulk,项目名称:croogo,代码行数:17,代码来源:NodeApiComponent.php

示例7: _setupRole

 /**
  * Hook admin menu element to set role parent
  */
 protected function _setupRole()
 {
     $title = __d('croogo', 'Parent Role');
     $element = 'Acl.admin/parent_role';
     Croogo::hookAdminTab('Roles/admin_add', $title, $element);
     Croogo::hookAdminTab('Roles/admin_edit', $title, $element);
     $this->_controller->Role->bindAro();
     $id = null;
     if (!empty($this->_controller->request->params['pass'][0])) {
         $id = $this->_controller->request->params['pass'][0];
     }
     $this->_controller->set('parents', $this->_controller->Role->allowedParents($id));
 }
开发者ID:saydulk,项目名称:croogo,代码行数:16,代码来源:AclAccessComponent.php

示例8: setReferer

 /**
  * Store referer data in view $referer variable
  *
  * @param string $default
  */
 public function setReferer($default = null)
 {
     if (empty($this->Controller->request->data['Data']['referer'])) {
         $referer = $this->Controller->request->referer();
         if ($referer == '/' && !empty($default)) {
             $referer = $default;
             if (is_array($referer)) {
                 $referer = Router::url($referer);
             }
         }
     } else {
         $referer = $this->Controller->request->data['Data']['referer'];
     }
     $this->Controller->set(compact('referer'));
 }
开发者ID:tetsuo111,项目名称:cakephp,代码行数:20,代码来源:RefererComponent.php

示例9: beforeRender

 /**
  * An action or view is being overridden, so prepare the layout and environment.
  * Bind any other data that should be present.
  *
  * @param Controller $controller
  */
 public function beforeRender(Controller $controller)
 {
     $badges = array();
     foreach (Configure::read('Admin.menu') as $section => $menu) {
         $badges[$section] = $menu['count'];
     }
     $controller->set('badgeCounts', $badges);
     if (isset($controller->Model)) {
         $controller->set('model', $controller->Model);
     }
     if (isset($controller->request->params['override'])) {
         $controller->layout = 'Admin.admin';
         $controller->request->params['action'] = str_replace('admin_', '', $controller->action);
     }
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:21,代码来源:AdminToolbarComponent.php

示例10: startup

 public function startup(Controller $controller)
 {
     if (!isset($controller->request->params['named']['CakeUILocalStorageName'])) {
         return;
     }
     $options = $controller->request->data['CakeUILocalStorage'];
     $model = $options['model'];
     if ($controller->request->params['named']['CakeUIOperation'] == 1) {
         //Display modal window
         if (isset($controller->request->data[$model])) {
             $data[$model] = $controller->request->data[$model][$controller->request->params['named']["CakeUIRowId"]];
             $controller->request->data = $data;
             $controller->request->data['CakeUITemp']['key'] = $controller->request->params['named']["CakeUIRowId"];
         }
         $controller->set(compact('options'));
         // $controller->set("cakeUICookie",$controller->request->params['named']["CakeUICookie"]);
         $controller->set("CakeUILocalStorageName", $controller->request->params['named']['CakeUILocalStorageName']);
         echo $controller->render($options["element"]);
         die;
     } else {
         if ($controller->request->params['named']['CakeUIOperation'] == 2) {
             //Add or update
             $controller->set(compact('options'));
             $controller->set("CakeUILocalStorageName", $controller->request->params['named']['CakeUILocalStorageName']);
             if ($this->model->{$model}->saveAll($controller->request->data, array('validate' => 'only'))) {
                 $controller->set('requestData', $controller->request->data);
                 echo $controller->render($options["return_element"]);
             } else {
                 $controller->Session->setFlash(__('Não foi possível adicionar este item'), 'default', array('class' => 'alert alert-danger'), 'modalMsg');
                 echo $controller->render($options["element"]);
             }
             die;
         } else {
             if ($controller->request->params['named']['CakeUIOperation'] == 3) {
                 //Delete
                 $id = $controller->request->params['named']["CakeUIRecordId"];
                 $this->model->{$model}->id = $id;
                 if (!$this->model->{$model}->exists()) {
                     throw new NotFoundException(__('Item inválido 1'));
                 }
                 if ($this->model->{$model}->delete($id, true)) {
                     die;
                 }
                 throw new NotFoundException(__('Item inválido 2'));
             }
         }
     }
 }
开发者ID:piotr0beschel,项目名称:CakeUI,代码行数:48,代码来源:childFormComponent.php

示例11: respond

 public function respond()
 {
     $this->Controller->layout = "empty";
     $this->Controller->viewClass = "Media.Json";
     $this->Controller->set('uploadResponse', $this->Upload->toArray());
     $this->Controller->set('json', 'uploadResponse');
 }
开发者ID:fm-labs,项目名称:cakephp-media,代码行数:7,代码来源:_UploadifyComponent.php

示例12: startup

 /**
  * 会員項目のレイアウトに必要なデータを取得し、viewにセットする
  *
  * @param Controller $controller コントローラ
  * @return void
  * @link http://book.cakephp.org/2.0/ja/controllers/components.html#Component::startup Component::startup
  */
 public function startup(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     //Modelの呼び出し
     $controller->UserAttributeLayout = ClassRegistry::init('UserAttributes.UserAttributeLayout');
     $controller->UserAttribute = ClassRegistry::init('UserAttributes.UserAttribute');
     //UserAttributeデータセット
     $userAttributes = $controller->UserAttribute->getUserAttributesForLayout();
     $controller->set('userAttributes', $userAttributes);
     //UserAttributeLayoutデータセット
     $userAttributeLayouts = $controller->UserAttributeLayout->find('all', array('fields' => array('id', 'col'), 'recursive' => -1, 'order' => array('id' => 'asc')));
     $controller->set('userAttributeLayouts', $userAttributeLayouts);
 }
开发者ID:NetCommons3,项目名称:UserAttributes,代码行数:23,代码来源:UserAttributeLayoutComponent.php

示例13: _viewAction

 /**
  * Generic view action
  *
  * Triggers the following callbacks
  *	- Crud.init
  *	- Crud.beforeFind
  *	- Crud.recordNotFound
  *	- Crud.afterFind
  *	- Crud.beforeRender
  *
  * @param string $id
  * @return void
  */
 protected function _viewAction($id = null)
 {
     if (empty($id)) {
         $id = $this->getIdFromRequest();
     }
     $this->_validateId($id);
     // Build conditions
     $query = array();
     $query['conditions'] = array($this->_model->escapeField() => $id);
     $findMethod = $this->_getFindMethod(null, 'first');
     $subject = $this->trigger('beforeFind', compact('id', 'query', 'findMethod'));
     $query = $subject->query;
     // Try and find the database record
     $item = $this->_model->find($subject->findMethod, $query);
     // We could not find any record match the conditions in query
     if (empty($item)) {
         $subject = $this->trigger('recordNotFound', compact('id'));
         $this->_setFlash('find.error');
         return $this->_redirect($subject, array('action' => 'index'));
     }
     // We found a record, trigger an afterFind
     $subject = $this->trigger('afterFind', compact('id', 'item'));
     $item = $subject->item;
     // Push it to the view
     $this->_controller->set(compact('item'));
     // Trigger a beforeRender
     $this->trigger('beforeRender', compact('id', 'item'));
 }
开发者ID:nodesagency,项目名称:Platform-Crud-Plugin,代码行数:41,代码来源:CrudComponent.php

示例14: initialize

 public function initialize(Controller $controller)
 {
     if ($controller->request->params['controller'] == "nodes") {
         switch ($controller->request->params['action']) {
             case 'admin_edit':
                 $compare = true;
                 $compare = is_numeric($controller->request->params['pass'][0]);
                 if ($compare) {
                     $rq = $controller->Node->findById($controller->request->params['pass'][0]);
                     $controller->set(array('Multiattach' => $rq['Multiattach']));
                     $controller->set(array('node_id' => $controller->request->params['pass'][0]));
                 }
                 break;
         }
     }
 }
开发者ID:issasouktel,项目名称:Multiattach,代码行数:16,代码来源:MultiattachesComponent.php

示例15: index

	public function index($params){
		
		$bookings = $this->db->getOnlineBooking();
		
		parent::set('bookings', $bookings);
		parent::set('active', 'online_booking');
	}
开发者ID:ndusan,项目名称:belvi,代码行数:7,代码来源:cms_online_bookingController.class.php


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