當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::set方法代碼示例

本文整理匯總了PHP中Cake\View\View::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::set方法的具體用法?PHP View::set怎麽用?PHP View::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\View\View的用法示例。


在下文中一共展示了View::set方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _testEnabled

 private function _testEnabled($method = 'GET')
 {
     $request = new Request();
     $request->env('REQUEST_METHOD', $method);
     $request->here = '/pages/home';
     $response = new Response();
     $View = new View($request, $response);
     $View->loadHelper('ViewMemcached.ViewMemcached', ['cacheConfig' => TEST_CACHE_CONFIG]);
     $View->viewPath = 'Pages';
     $View->set('test', 'value');
     $View->render('home', 'default');
     return $View->ViewMemcached->enabled();
 }
開發者ID:chnvcode,項目名稱:cakephp-viewmemcached,代碼行數:13,代碼來源:ViewMemcachedHelperTest.php

示例2: testRoles

 /**
  * @return void
  */
 public function testRoles()
 {
     $this->AuthUserHelper->config('multiRole', true);
     $user = ['id' => '1', 'Roles' => ['1', '2']];
     $this->View->set('_authUser', $user);
     $this->assertSame(['user' => '1', 'moderator' => '2'], $this->AuthUserHelper->roles());
 }
開發者ID:dereuromark,項目名稱:cakephp-tinyauth,代碼行數:10,代碼來源:AuthUserHelperTest.php

示例3: get_for_parent

 public function get_for_parent($parent, $page)
 {
     $comments = $this->Comments->find()->where(['Comments.object_id' => $parent])->limit(__MAX_COMMENTS_LISTED)->page($page)->order('Comments.created DESC')->contain(['Authors' => ['fields' => ['id', 'first_name', 'last_name', 'avatar']]]);
     // Reorder the Comments by creation order
     // (even though we got them by descending order)
     $collection = new Collection($comments);
     $comments = $collection->sortBy('Comment.created');
     $view = new View($this->request, $this->response, null);
     $view->layout = 'ajax';
     // layout to use or false to disable
     $view->set('comments', $comments->toArray());
     $data['html'] = $view->render('Social.Comments/get_for_parent');
     $this->layout = 'ajax';
     $this->set('data', $data);
     $this->render('/Shared/json/data');
 }
開發者ID:eripoll,項目名稱:webiplan,代碼行數:16,代碼來源:CommentsController.php

示例4: notifications

 public function notifications($user = null, $page = 1)
 {
     // Getting the Activities personalized feed
     // NEW : User must subscribe individually to each Pole's Feed to be notified.
     // We only get the Activities for which the User is not the creator
     // that were created after the last time he read them.
     if (!$user) {
         $user = $this->loggedInUser->id;
     }
     // Then get all the subscriptions
     $Subscriptions = TableRegistry::get('Social.Subscriptions');
     $subscriptions = $Subscriptions->find()->where(['Subscriptions.user_id' => $user])->all();
     $subscriptions = (new Collection($subscriptions))->extract('feed_id')->toArray();
     $query = $this->Activities->find()->contain(['Authors' => ['fields' => ['id', 'first_name', 'last_name', 'avatar']]])->limit(__MAX_NOTIFICATIONS_LISTED)->page($page)->order(['Activities.created DESC'])->matching('Feeds', function ($q) use($subscriptions) {
         return $q->where(['Feeds.id IN' => $subscriptions]);
     });
     if ($this->request->is('ajax')) {
         if (isset($this->request->query['last_check'])) {
             $last_check = Time::createFromTimestamp($this->request->query['last_check'] / 1000);
             $activities = $query->where(['Activities.subject_id !=' => $user, 'Activities.created >' => $last_check->format('Y-m-d H:i:s')])->all();
         } else {
             $activities = $query->where(['Activities.subject_id !=' => $user])->all();
         }
         $count = $this->Activities->find()->contain(['Authors' => ['fields' => ['id', 'first_name', 'last_name', 'avatar']]])->limit(20000)->order(['Activities.created DESC'])->where(['Activities.subject_id !=' => $user, 'Activities.created >' => $this->loggedInUser->notifications_last_read])->matching('Feeds', function ($q) use($subscriptions) {
             return $q->where(['Feeds.id IN' => $subscriptions]);
         })->count();
         $view = new View($this->request, $this->response, null);
         $view->layout = 'ajax';
         // layout to use or false to disable
         $view->set('loggedInUser', $this->loggedInUser);
         $view->set('all_poles', $this->all_poles->toArray());
         $view->set('activities', $activities->toArray());
         $data['html'] = $view->render('Social.Activities/ajax_notifications');
         $this->layout = 'ajax';
         $data['count'] = $count;
         $data['success'] = true;
         $this->set('data', $data);
         $this->render('/Shared/json/data');
     } else {
         $activities = $query->where(['Activities.subject_id !=' => $user])->all();
         $this->set('activities', $activities->toArray());
         // UI
         $this->set('section_title', __('Notifications'));
         $this->set('page_title', __('Notifications'));
         // Handling the breadcrumb
         $this->breadcrumb = array(__('Notifications') => '#');
     }
 }
開發者ID:eripoll,項目名稱:webiplan,代碼行數:48,代碼來源:ActivitiesController.php

示例5: pdf

 /**
  * Generate PDF
  * @param $id
  */
 public function pdf($id = null)
 {
     $row = $this->Orders->findById($id)->contain(["Users", "Statuses", "Operations", "Accessories", "Images"])->first();
     if (!$row) {
         throw new InternalErrorException("Chyba pri nacitani objednavky", 500);
     }
     $view = new View($this->request, $this->response, null);
     $view->layout = "ajax";
     $view->set("row", $row);
     $html = $view->render("Orders/pdf");
     $pdf = new \DOMPDF();
     $pdf->load_html(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
     $pdf->set_paper('a4', 'portrait');
     $pdf->render();
     $pdf->stream("order-" . $id . ".pdf", array("Attachment" => 0));
 }
開發者ID:ranostaj,項目名稱:autocar,代碼行數:20,代碼來源:OrdersController.php


注:本文中的Cake\View\View::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。