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


PHP View::setBasePath方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\View::setBasePath方法的典型用法代码示例。如果您正苦于以下问题:PHP View::setBasePath方法的具体用法?PHP View::setBasePath怎么用?PHP View::setBasePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\View的用法示例。


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

示例1: testStandardRender

 public function testStandardRender()
 {
     $view = new View();
     $view->setBasePath(__DIR__ . '/../');
     $view->setViewsDir('unit-tests/views/');
     $this->assertEquals($view->getViewsDir(), 'unit-tests/views/');
     //Standard Render
     $view->start();
     $view->render('test2', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>here</html>' . PHP_EOL);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lolhere</html>' . PHP_EOL);
     //Variables
     $view->setParamToView('a_cool_var', 'le-this');
     $view->start();
     $view->render('test3', 'another');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lol<p>le-this</p></html>' . PHP_EOL);
     //Templates
     $view->setTemplateAfter('test');
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>zuplolhere</html>' . PHP_EOL);
     $view->cleanTemplateAfter();
     //Render Levels
     $view->setRenderLevel(View::LEVEL_MAIN_LAYOUT);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lolhere</html>' . PHP_EOL);
     $view->setRenderLevel(View::LEVEL_LAYOUT);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), 'lolhere');
     $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), 'here');
     //Pick View
     $view->setRenderLevel(View::LEVEL_MAIN_LAYOUT);
     $view->start();
     $view->pick('test3/yup');
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lolyup</html>' . PHP_EOL);
     //No Render
     $view->setRenderLevel(View::LEVEL_NO_RENDER);
     $view->start();
     $view->pick('test3/yup');
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '');
 }
开发者ID:racklin,项目名称:cphalcon,代码行数:59,代码来源:ViewTest.php

示例2: testBasic

 public function testBasic()
 {
     $di = new Phalcon\DI\FactoryDefault();
     $di['view'] = function () {
         $view = new View();
         $view->setBasePath(__DIR__ . '/../')->setViewsDir('unit-tests/views/');
         return $view;
     };
     $viewmodel = new ViewModel();
     $viewmodel->label = 'phalcon';
     $viewmodel->setTemplate('model/model1');
     $this->assertEquals('phalcon', $viewmodel->label);
     $viewmodel1 = new ViewModel(array('label' => 'First child'), 'model/model2');
     $viewmodel2 = new Phalcon\Mvc\View\Model(['label' => 'Second child'], 'model/model2', 'child2');
     $viewmodel->addChild($viewmodel1, 'child1');
     $viewmodel->addChild($viewmodel2);
     $content = $viewmodel->render();
     $this->assertEquals($content, '<ul>phalcon<li>First child</li><li>Second child</li></ul>');
     $viewmodel3 = new Phalcon\Mvc\View\Model(['label' => 'append'], 'model/model2', 'child1');
     $viewmodel->appendChild($viewmodel3);
     $content = $viewmodel->render();
     var_dump($viewmodel->child1);
     $this->assertEquals($content, '<ul>phalcon<li>First child</li><li>append</li><li>Second child</li></ul>');
 }
开发者ID:UqiOnline,项目名称:cphalcon7,代码行数:24,代码来源:ViewModelTest.php

示例3: testPartials

 public function testPartials()
 {
     $view = new Phalcon\Mvc\View();
     $view->setBasePath(__DIR__ . '/../');
     $view->setViewsDir('unit-tests/views/');
     $this->assertEquals($view->getViewsDir(), 'unit-tests/views/');
     $view->setParamToView('cool_var', 'le-this');
     $view->start();
     $view->render('test5', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Hey, this is a partial, also le-this</html>' . PHP_EOL);
     $view->start();
     $view->render('test9', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Hey, this is a partial, also le-this<br />Hey, this is a second partial, also le-this</html>' . PHP_EOL);
 }
开发者ID:racklin,项目名称:cphalcon,代码行数:16,代码来源:ViewTest.php

示例4: testIssue2140

 public function testIssue2140()
 {
     $view = new View();
     $view->setBasePath(__DIR__ . '/../');
     $view->setViewsDir('unit-tests/views/');
     $html = $view->partial('test2/index', NULL, FALSE);
     $this->assertEquals($html, 'here');
 }
开发者ID:UqiOnline,项目名称:cphalcon7,代码行数:8,代码来源:ViewTest.php

示例5: testIssue907

 public function testIssue907()
 {
     $view = new View();
     $view->setBasePath(__DIR__ . '/../');
     $view->setViewsDir('unit-tests/views/');
     $listener = new \ViewAfterRenderListener();
     $eventsManager = new \Phalcon\Events\Manager();
     $eventsManager->attach('view', $listener);
     $view->setEventsManager($eventsManager);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lolhere</html>' . PHP_EOL);
     $this->assertEquals('1,3,5', $listener->getLevels());
     $listener->reset();
     //Templates
     $view->setTemplateAfter('test');
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>zuplolhere</html>' . PHP_EOL);
     $this->assertEquals('1,3,4,5', $listener->getLevels());
     $listener->reset();
     $view->cleanTemplateAfter();
     //Render Levels
     $view->setRenderLevel(View::LEVEL_MAIN_LAYOUT);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>lolhere</html>' . PHP_EOL);
     $this->assertEquals('1,3,5', $listener->getLevels());
     $listener->reset();
     $view->setRenderLevel(View::LEVEL_LAYOUT);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), 'lolhere');
     $this->assertEquals('1,3', $listener->getLevels());
     $listener->reset();
     $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     $view->start();
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), 'here');
     $this->assertEquals('1', $listener->getLevels());
     $listener->reset();
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:47,代码来源:ViewTest.php


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