當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::pick方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\View::pick方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::pick方法的具體用法?PHP View::pick怎麽用?PHP View::pick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\View的用法示例。


在下文中一共展示了View::pick方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: pickCustom

 /**
  * Pick view to render.
  *
  * @param array|string $renderView View to render.
  *
  * @return PhalconView|void
  */
 public function pickCustom($renderView)
 {
     if ($this->theme != null) {
         $renderView = '../themes/' . $this->theme . '/' . $renderView;
     }
     parent::pick($renderView);
 }
開發者ID:gitter-badger,項目名稱:phanbook,代碼行數:14,代碼來源:View.php

示例3: pick

 /**
  * Pick view to render.
  *
  * @param array|string $renderView View to render.
  * @param string|null  $module     Specify module.
  * @param bool|null    $finalView  This view will be final in pick process.
  *
  * @return $this
  */
 public function pick($renderView, $module = null, $finalView = null)
 {
     if ($finalView !== null) {
         $this->_finalView = $finalView;
     }
     parent::pick($this->resolveView($renderView, $module));
 }
開發者ID:phalconeye,項目名稱:framework,代碼行數:16,代碼來源:View.php

示例4: testLayoutAndPick

 public function testLayoutAndPick()
 {
     $view = new View();
     $view->setViewsDir('unit-tests/views/');
     // Pick string
     $view->start();
     $view->setLayout('test6');
     $view->pick('test3/other');
     $view->render('test3', 'another');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Well, this is the view content: here.</html>' . PHP_EOL);
     // Pick array
     $view->start();
     $view->setLayout('test6');
     $view->pick(array('test3/other'));
     $view->render('test3', 'another');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Well, this is the view content: here.</html>' . PHP_EOL);
 }
開發者ID:mattvb91,項目名稱:cphalcon,代碼行數:19,代碼來源:ViewTest.php

示例5: pick

 /**
  * Pick view to render.
  *
  * @param array|string $renderView View to render.
  * @param string|null  $module     Specify module.
  *
  * @return PhalconView|void
  */
 public function pick($renderView, $module = null)
 {
     if ($module != null) {
         $renderView = '../../' . ucfirst($module) . '/View/' . $renderView;
     }
     parent::pick($renderView);
 }
開發者ID:biggtfish,項目名稱:cms,代碼行數:15,代碼來源:View.php

示例6: 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('');
     });
 }
開發者ID:phalcon,項目名稱:cphalcon,代碼行數:59,代碼來源:ViewTest.php


注:本文中的Phalcon\Mvc\View::pick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。