• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP View\View类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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)
    {
        $cache = [];
        if ($this->_cache) {
            $cache = $this->_cacheConfig($this->action);
        }

        $render = function () use ($template) {
            try {
                $reflect = new ReflectionMethod($this, $this->action);
                $reflect->invokeArgs($this, $this->args);
            } catch (ReflectionException $e) {
                throw new BadMethodCallException(sprintf(
                    'Class %s does not have a "%s" method.',
                    get_class($this),
                    $this->action
                ));
            }

            $builder = $this->viewBuilder();

            if ($template !== null &&
                strpos($template, '/') === false &&
                strpos($template, '.') === false
            ) {
                $template = Inflector::underscore($template);
            }
            if ($template === null) {
                $template = $builder->template() ?: $this->template;
            }
            $builder->layout(false)
                ->template($template);

            $className = get_class($this);
            $namePrefix = '\View\Cell\\';
            $name = substr($className, strpos($className, $namePrefix) + strlen($namePrefix));
            $name = substr($name, 0, -4);
            if (!$builder->templatePath()) {
                $builder->templatePath('Cell' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $name));
            }

            $this->View = $this->createView();
            try {
                return $this->View->render($template);
            } catch (MissingTemplateException $e) {
                throw new MissingCellViewException(['file' => $template, 'name' => $name]);
            }
        };

        if ($cache) {
            return Cache::remember($cache['key'], $render, $cache['config']);
        }

        return $render();
    }
开发者ID:TeachersPayTeachers,项目名称:cakephp,代码行数:63,代码来源:Cell.php


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


示例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('MyUtils');
 }
开发者ID:ericgarn77,项目名称:admin_src,代码行数:15,代码来源:AppView.php


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


示例17: render

 public function render($view = null, $layout = null)
 {
     // !IMPORTANT: Render view before initializing CakeTcpdf, because TCPDF sets the encoding to ASCII
     $content = parent::render($view, $layout);
     $pdfParams = $this->get('pdf');
     $this->engine()->SetTitle($pdfParams['title']);
     $this->engine()->SetSubject($pdfParams['subject']);
     $this->engine()->SetKeywords($pdfParams['keywords']);
     Configure::write('debug', false);
     $this->engine()->AddPage();
     $this->engine()->writeHTML($content, true, 0, true, 0);
     $filename = isset($pdfParams['filename']) ? $pdfParams['filename'] : 'document.pdf';
     $output = isset($pdfParams['output']) ? $pdfParams['output'] : 'S';
     switch (strtoupper($output)) {
         case "D":
             // force download
             return $this->engine()->Output($filename, 'D');
         case "I":
             // send to browser
             return $this->engine()->Output('', 'I');
         case "F":
             // save to disk
             return $this->engine()->Output(TMP . $filename, 'F');
         case "FD":
             // save to disk and force download
             return $this->engine()->Output(TMP . $filename, 'FD');
         case "S":
         default:
             // send as application/pdf response
             $this->response->type('pdf');
             $this->response->header('Content-Disposition: inline; filename="' . $filename . '"');
             return $this->engine()->Output('', 'S');
     }
 }
开发者ID:fm-labs,项目名称:cakephp-tcpdf,代码行数:34,代码来源:PdfView.php


示例18: 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();
     if (Configure::read('Facebook.app_id')) {
         $this->loadHelper('JorgeFacebook.Facebook');
     }
 }
开发者ID:jorgejardim,项目名称:cakephp-skeleton-systems,代码行数:15,代码来源:AppView.php


示例19: 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();
     if ($this->request->action === 'add') {
         //$this->loadHelper('Tag.TagCloud');
     }
 }
开发者ID:matthiasmoritz,项目名称:exlibris,代码行数:15,代码来源:AppView.php


示例20: 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('Flash');
     $this->loadHelper('Number');
     $this->loadHelper('Text');
     $this->loadHelper('Time');
 }
开发者ID:array-pop-tarts,项目名称:flimsy,代码行数:16,代码来源:AppView.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Carbon\Carbon类代码示例发布时间:2022-05-23
下一篇:
PHP View\Helper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap