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


PHP View\View类代码示例

本文整理汇总了PHP中Cake\View\View的典型用法代码示例。如果您正苦于以下问题:PHP View类的具体用法?PHP View怎么用?PHP View使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: beforeDispatch

 /**
  * Checks whether the response was cached and set the body accordingly.
  *
  * @param \Cake\Event\Event $event containing the request and response object
  * @return \Cake\Network\Response with cached content if found, null otherwise
  */
 public function beforeDispatch(Event $event)
 {
     if (Configure::read('Cache.check') !== true) {
         return;
     }
     $path = $event->data['request']->here();
     if ($path === '/') {
         $path = 'home';
     }
     $prefix = Configure::read('Cache.viewPrefix');
     if ($prefix) {
         $path = $prefix . '_' . $path;
     }
     $path = strtolower(Inflector::slug($path));
     $filename = CACHE . 'views/' . $path . '.php';
     if (!file_exists($filename)) {
         $filename = CACHE . 'views/' . $path . '_index.php';
     }
     if (file_exists($filename)) {
         $controller = null;
         $view = new View($controller);
         $view->response = $event->data['response'];
         $result = $view->renderCache($filename, microtime(true));
         if ($result !== false) {
             $event->stopPropagation();
             $event->data['response']->body($result);
             return $event->data['response'];
         }
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:36,代码来源:CacheDispatcher.php

示例2: _getView

 /**
  * Prepares a View instance with which the given view file
  * will be rendered.
  *
  * @return View
  */
 protected function _getView()
 {
     $view = new View();
     foreach ($this->config('helpers') as $helper) {
         $view->loadHelper($helper);
     }
     return $view;
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:14,代码来源:PdfGenerator.php

示例3: testIsAuthorized

 /**
  * Test isAuthorized
  *
  * @return void
  */
 public function testIsAuthorized()
 {
     $view = new View();
     $eventManagerMock = $this->getMockBuilder('Cake\\Event\\EventManager')->setMethods(['dispatch'])->getMock();
     $view->eventManager($eventManagerMock);
     $this->AuthLink = new AuthLinkHelper($view);
     $result = new Event('dispatch-result');
     $result->result = true;
     $eventManagerMock->expects($this->once())->method('dispatch')->will($this->returnValue($result));
     $result = $this->AuthLink->isAuthorized(['controller' => 'MyController', 'action' => 'myAction']);
     $this->assertTrue($result);
 }
开发者ID:cakedc,项目名称:users,代码行数:17,代码来源:AuthLinkHelperTest.php

示例4: testLogWriting

 /**
  * Tests the log write method
  *
  * @return void
  */
 public function testLogWriting()
 {
     $View = new View();
     $countBefore = $this->Logs->find()->count();
     $View->log('x');
     $View->log('warning', LOG_WARNING);
     Log::write(LOG_ERR, 'y');
     Log::write(LOG_INFO, 'z');
     $countAfter = $this->Logs->find()->count();
     $this->assertSame($countBefore + 8, $countAfter);
     // should be 4 (but for some reason everything is added twice
 }
开发者ID:dereuromark,项目名称:cakephp-databaselog,代码行数:17,代码来源:DatabaseLogTest.php

示例5: render

 /**
  * Render the cell.
  *
  * @param string|null $template Custom template name to render. If not provided (null), the last
  * value will be used. This value is automatically set by `CellTrait::cell()`.
  * @return string The rendered cell.
  * @throws \Cake\View\Exception\MissingCellViewException When a MissingTemplateException is raised during rendering.
  */
 public function render($template = null)
 {
     if ($template !== null && strpos($template, '/') === false && strpos($template, '.') === false) {
         $template = Inflector::underscore($template);
     }
     if ($template === null) {
         $template = $this->template;
     }
     $builder = $this->viewBuilder();
     $builder->layout(false);
     $builder->template($template);
     $cache = [];
     if ($this->_cache) {
         $cache = $this->_cacheConfig($template);
     }
     $this->View = $this->createView();
     $render = function () use($template) {
         $className = substr(strrchr(get_class($this), "\\"), 1);
         $name = substr($className, 0, -4);
         $this->View->templatePath('Cell' . DS . $name);
         try {
             return $this->View->render($template);
         } catch (MissingTemplateException $e) {
             throw new MissingCellViewException(['file' => $template, 'name' => $name]);
         }
     };
     if ($cache) {
         return $this->View->cache(function () use($render) {
             echo $render();
         }, $cache);
     }
     return $render();
 }
开发者ID:a53ali,项目名称:CakePhP,代码行数:41,代码来源:Cell.php

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

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

示例8: __construct

 /**
  * Constructor
  *
  * @param \Cake\Network\Request $request The request object.
  * @param \Cake\Network\Response $response The response object.
  * @param \Cake\Event\EventManager $eventManager Event manager object.
  * @param array $viewOptions View options.
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     parent::__construct($request, $response, $eventManager, $viewOptions);
     if ($response && $response instanceof Response) {
         $response->type('ajax');
     }
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:15,代码来源:AjaxView.php

示例9: formatter

 /**
  * Renders the given custom field.
  *
  * @param \Cake\View\View $view Instance of view class
  * @param \Field\Model\Entity\Field $field The field to be rendered
  * @return string HTML code
  */
 public static function formatter($view, $field)
 {
     switch ($field->viewModeSettings['formatter']) {
         case 'link':
             $out = $view->element('Field.FileField/display_link', compact('field'));
             break;
         case 'table':
             $out = $view->element('Field.FileField/display_table', compact('field'));
             break;
         case 'url':
         default:
             $out = $view->element('Field.FileField/display_url', compact('field'));
             break;
     }
     return $out;
 }
开发者ID:quickapps-plugins,项目名称:field,代码行数:23,代码来源:FileToolbox.php

示例10: __construct

 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     parent::__construct($request, $response, $eventManager, $viewOptions);
     $this->_serviceProvider = new ServiceProvider(Configure::read('App.paths.templates'), CACHE . 'bladeView');
     $this->loadBlade();
     $this->_loadHelpers();
     $this->loadExtensions();
 }
开发者ID:xety,项目名称:cake3-blade,代码行数:8,代码来源:BladeView.php

示例11: initialize

 /**
  * Initialization hook method.
  *
  * For e.g. use this method to load a helper for all views:
  * `$this->loadHelper('Html');`
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     //        $this->loadHelper('Html', ['className' => 'BootstrapUI.Html']);
     //        $this->loadHelper('Form', ['className' => 'BootstrapUI.Form']);
     //        $this->loadHelper('Flash', ['className' => 'BootstrapUI.Flash']);
     //        $this->loadHelper('Paginator', ['className' => 'BootstrapUI.Paginator']);
     $this->eventManager()->dispatch(new Event('Spider.SpiderAppView.initialize', $this));
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:17,代码来源:SpiderAppView.php

示例12: _getViewFileName

 /**
  * Returns filename of given action's template file (.ctp) as a string.
  * CamelCased action names will be under_scored! This means that you can have
  * LongActionNames that refer to long_action_names.ctp views.
  *
  * @param string $name Controller action to find template filename for
  * @return string Template filename
  * @throws \Cake\View\Exception\MissingViewException when a view file could not be found.
  */
 protected function _getViewFileName($name = null)
 {
     try {
         $result = parent::_getViewFileName($name);
     } catch (MissingViewException $e) {
         throw new Exception\MissingDashboardException($e->getMessage());
     }
     return $result;
 }
开发者ID:gourmet,项目名称:dashboard,代码行数:18,代码来源:View.php

示例13: getFunctions

 /**
  * Get declared functions.
  *
  * @return \Twig_SimpleFunction[]
  */
 public function getFunctions()
 {
     return [new \Twig_SimpleFunction('elementExists', function ($name) {
         return $this->view->elementExists($name);
     }), new \Twig_SimpleFunction('getVars', function () {
         return $this->view->getVars();
     }), new \Twig_SimpleFunction('get', function ($var, $default = null) {
         return $this->view->get($var, $default);
     })];
 }
开发者ID:luisfredgs,项目名称:TwigView,代码行数:15,代码来源:View.php

示例14: initialize

 /**
  * Initialization hook method.
  *
  * For e.g. use this method to load a helper for all views:
  * `$this->loadHelper('Html');`
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     $this->loadHelper('Html');
     $this->loadHelper('Form');
     $this->loadHelper('MyUtils');
 }
开发者ID:ericgarn77,项目名称:admin_src,代码行数:15,代码来源:AppView.php

示例15: initialize

 /**
  * Initialization hook method.
  *
  * For e.g. use this method to load a helper for all views:
  * `$this->loadHelper('Html');`
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     //     	$this->loadHelper('Html');
     //     	$this->loadHelper('Form');
     //     	$this->loadHelper('Flash');
 }
开发者ID:TranBinhLuan,项目名称:junzeron,代码行数:15,代码来源:AppView.php


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