当前位置: 首页>>代码示例>>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;未经允许,请勿转载。