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


PHP View::getViewsDir方法代码示例

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


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

示例1: render

 /**
  * {@inheritdoc}
  */
 public function render($params = array())
 {
     $currentViewsDir = $this->view->getViewsDir();
     $this->view->setViewsDir($this->getServiceViewPath());
     $this->view->disableLevel(View::LEVEL_LAYOUT);
     $content = $this->view->getRender('services', $this->templateName, $params);
     //rollback viewsDir
     $this->view->setViewsDir($currentViewsDir);
     return $content;
 }
开发者ID:arius86,项目名称:core,代码行数:13,代码来源:Renderer.php

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

示例3: getLayoutDir

 /**
  * @param string $layout
  *
  * @return string
  */
 protected function getLayoutDir($layout)
 {
     $views_dir = $this->_view->getViewsDir();
     $type = $this->getType();
     if (!file_exists($views_dir . $type . '/' . $layout . '.phtml')) {
         return 'Field';
     }
     return $type;
 }
开发者ID:moaljazaery,项目名称:phalcon-module-admin,代码行数:14,代码来源:Field.php

示例4: _viewRender

 /**
  * Render template.
  *
  * @param string $template Template name.
  * @param array  $params   Template params.
  *
  * @return string
  */
 private function _viewRender($template, $params)
 {
     ob_start();
     $viewsDir = $this->_view->getViewsDir();
     $this->_view->setViewsDir(ROOT_PATH . '/app/modules/Core/View/');
     $this->_view->partial('partials/profiler/' . $template, $params);
     $this->_view->setViewsDir($viewsDir);
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
开发者ID:biggtfish,项目名称:cms,代码行数:19,代码来源:Profiler.php

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

示例6: getFiles

 protected function getFiles()
 {
     return Finder::findFiles('*.mustache')->from($this->view->getViewsDir());
 }
开发者ID:kathynka,项目名称:Foundation,代码行数:4,代码来源:MustacheTemplateAssets.php

示例7: function

$di->set('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
}, true);
/**
* Setting up the view component
*/
$di->setShared('view', function () use($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
        $volt->getCompiler()->addFunction('include_raw', function ($resolvedArgs, $exprArgs) use($view) {
            return sprintf('file_get_contents("%s" . %s)', $view->getViewsDir(), $resolvedArgs);
        });
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
});
/**
 * Flash service with custom CSS classes
 */
$di->set('flash', function () {
    return new Flash(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
});
/**
*   Inject graph connection, repositories, etc
*/
/* gRPC configuration */
开发者ID:netassist-ua,项目名称:netgraphz2-gpl,代码行数:31,代码来源:services.php


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