當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。