本文整理汇总了PHP中Phalcon\Mvc\View::cleanTemplateAfter方法的典型用法代码示例。如果您正苦于以下问题:PHP View::cleanTemplateAfter方法的具体用法?PHP View::cleanTemplateAfter怎么用?PHP View::cleanTemplateAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::cleanTemplateAfter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(), '');
}
示例2: 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,6', $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,5,6', $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,6', $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();
}
示例3: testStandardRender
/**
* Tests View::render
*
* @author Andres Gutierrez <andres@phalconphp.com>
* @since 2012-03-05
*/
public function testStandardRender()
{
$this->specify('The View component does not work as expected', function () {
$view = new View();
$view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
$view->start();
$view->render('test2', 'index');
$view->finish();
expect($view->getContent())->equals("<html>We are here</html>\n");
$view->start();
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals("<html>lolhere</html>\n");
$view->setParamToView('a_cool_var', 'le-this');
$view->start();
$view->render('test3', 'another');
$view->finish();
expect($view->getContent())->equals("<html>lol<p>le-this</p></html>\n");
$view->setTemplateAfter('test');
$view->start();
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals("<html>zuplolhere</html>\n");
$view->cleanTemplateAfter();
$view->setRenderLevel(View::LEVEL_MAIN_LAYOUT);
$view->start();
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals("<html>lolhere</html>\n");
$view->setRenderLevel(View::LEVEL_LAYOUT);
$view->start();
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals('lolhere');
$view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$view->start();
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals('here');
$view->setRenderLevel(View::LEVEL_MAIN_LAYOUT);
$view->start();
$view->pick('test3/yup');
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals("<html>lolyup</html>\n");
$view->setRenderLevel(View::LEVEL_NO_RENDER);
$view->start();
$view->pick('test3/yup');
$view->render('test3', 'other');
$view->finish();
expect($view->getContent())->equals('');
});
}