本文整理汇总了PHP中Zend_Controller_Action_Helper_ViewRenderer::initView方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action_Helper_ViewRenderer::initView方法的具体用法?PHP Zend_Controller_Action_Helper_ViewRenderer::initView怎么用?PHP Zend_Controller_Action_Helper_ViewRenderer::initView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Action_Helper_ViewRenderer
的用法示例。
在下文中一共展示了Zend_Controller_Action_Helper_ViewRenderer::initView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initView
/**
* @param null $path
* @param null $prefix
* @param array $options
*/
public function initView($path = null, $prefix = null, array $options = array())
{
if (null === $this->view) {
$view = new View();
$view->setRequest($this->getRequest());
$view->addHelperPath(PIMCORE_PATH . "/lib/Pimcore/View/Helper", "\\Pimcore\\View\\Helper\\");
$this->setView($view);
}
parent::initView($path, $prefix, $options);
$this->setViewSuffix(View::getViewScriptSuffix());
// this is very important, the initView could be called multiple times.
// if we add the path on every call, we have big performance issues.
if ($this->isInitialized) {
return;
}
$this->isInitialized = true;
$paths = $this->view->getScriptPaths();
// script pathes for layout path
foreach (array_reverse($paths) as $path) {
$path = str_replace("\\", "/", $path);
if (!in_array($path, $paths)) {
$this->view->addScriptPath($path);
}
$path = str_replace("/scripts", "/layouts", $path);
if (!in_array($path, $paths)) {
$this->view->addScriptPath($path);
}
}
}
示例2: testInitViewWithOptions
public function testInitViewWithOptions()
{
$this->request->setModuleName('foo')->setControllerName('index');
$controller = new Foo_IndexController($this->request, $this->response, array());
$this->helper->setActionController($controller);
$viewDir = dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 2) . DIRECTORY_SEPARATOR . 'views';
$this->helper->initView($viewDir, 'Baz_Bat', array('neverRender' => true, 'noRender' => true, 'noController' => true, 'viewSuffix' => 'php', 'scriptAction' => 'foo', 'responseSegment' => 'baz'));
$this->assertTrue($this->helper->getNeverRender());
$this->assertTrue($this->helper->getNoRender());
$this->assertTrue($this->helper->getNoController());
$this->assertEquals('php', $this->helper->getViewSuffix());
$this->assertEquals('foo', $this->helper->getScriptAction());
$this->assertEquals('baz', $this->helper->getResponseSegment());
$scriptPaths = $this->helper->view->getScriptPaths();
$scriptPath = $scriptPaths[0];
$this->assertContains($viewDir, $scriptPath);
$helperPaths = $this->helper->view->getHelperPaths();
$found = false;
foreach ($helperPaths as $path) {
if ('Baz_Bat_Helper_' == $path['prefix']) {
$found = true;
}
}
$this->assertTrue($found, 'Helper prefix not set according to spec: ' . var_export($helperPaths, 1));
$filterPaths = $this->helper->view->getFilterPaths();
$found = false;
foreach ($filterPaths as $path) {
if ('Baz_Bat_Filter_' == $path['prefix']) {
$found = true;
}
}
$this->assertTrue($found, 'Filter prefix not set according to spec' . var_export($filterPaths, 1));
}
示例3: testStockInflectorWorksWithViewBaseSpec
/**
* @see ZF-2443
*/
public function testStockInflectorWorksWithViewBaseSpec()
{
$this->request->setModuleName('bar')->setControllerName('index')->setActionName('admin');
$controller = new Bar_IndexController($this->request, $this->response, array());
$this->helper->setActionController($controller);
$this->helper->setViewBasePathSpec(':moduleDir/:module');
$this->helper->initView();
$viewScriptPaths = $this->helper->view->getAllPaths();
$expectedPathRegex = '#modules/bar/bar/scripts/$#';
$this->assertRegExp($expectedPathRegex, $this->_normalizePath($viewScriptPaths['script'][0]));
$this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml');
}
示例4: testStockInflectorWorksWithViewBaseSpec
/**
* @see ZF-2443
*/
public function testStockInflectorWorksWithViewBaseSpec()
{
$this->request->setModuleName('bar')->setControllerName('index')->setActionName('admin');
$controller = new Bar_IndexController($this->request, $this->response, array());
$this->helper->setActionController($controller);
$this->helper->setViewBasePathSpec(':moduleDir/:module');
$this->helper->initView();
$viewScriptPaths = $this->helper->view->getAllPaths();
// we need this until View decides to not use DIRECTORY_SEPARATOR
$expectedPathRegex = DIRECTORY_SEPARATOR == '\\' ? '#modules\\\\bar\\\\bar\\\\scripts\\\\$#' : '#modules/bar/bar/scripts/$#';
$this->assertRegExp($expectedPathRegex, $viewScriptPaths['script'][0]);
$this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml');
}
示例5: initView
/**
* @param null $path
* @param null $prefix
* @param array $options
*/
public function initView($path = null, $prefix = null, array $options = array())
{
if (null === $this->view) {
$view = new Pimcore_View();
$view->setRequest($this->getRequest());
$view->addHelperPath(PIMCORE_PATH . "/lib/Pimcore/View/Helper", "Pimcore_View_Helper_");
$this->setView($view);
}
parent::initView($path, $prefix, $options);
// script pathes for layout path
foreach (array_reverse($this->view->getScriptPaths()) as $path) {
$path = str_replace("\\", "/", $path);
$this->view->addScriptPath($path);
$this->view->addScriptPath(str_replace("/scripts", "/layouts", $path));
}
$this->setViewSuffix(Pimcore_View::getViewScriptSuffix());
}
示例6: testStockInflectorWorksWithViewBaseSpec
/**
* @issue ZF-2443
*/
public function testStockInflectorWorksWithViewBaseSpec()
{
$this->request->setModuleName('bar') // bar must exist so the ViewRendere doesnt throw an exception
->setControllerName('index')
->setActionName('admin');
$controller = new Bar_IndexController($this->request, $this->response, array());
$this->helper->setActionController($controller);
$this->helper->setView($view = new Zend_View());
$this->helper->setViewBasePathSpec(':moduleDir/:module');
$this->helper->initView();
$viewScriptPaths = $view->getAllPaths();
$this->assertRegExp('#modules/bar/bar/scripts/$#', $viewScriptPaths['script'][0]);
$this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml');
}
示例7: testStockInflectorWorksWithViewBaseSpec
/**
* @group ZF-2443
*/
public function testStockInflectorWorksWithViewBaseSpec()
{
$this->request->setModuleName('bar') // bar must exist so the ViewRendere doesnt throw an exception
->setControllerName('index')
->setActionName('admin');
$controller = new \Bar\IndexController($this->request, $this->response, array());
$controller->setHelperBroker($this->broker);
$this->helper->setActionController($controller);
$this->helper->setViewBasePathSpec(':moduleDir/:module');
$this->helper->initView();
$viewScriptPaths = $this->helper->view->resolver()->getPaths();
$expectedPathRegex = '#modules/bar/bar/scripts/$#';
$this->assertRegExp(
$expectedPathRegex,
$this->_normalizePath($viewScriptPaths[0])
);
$this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml');
}
示例8: initView
/**
* Initialize the view object
*
* $options may contain the following keys:
* - neverRender - flag dis/enabling postDispatch() autorender (affects all subsequent calls)
* - noController - flag indicating whether or not to look for view scripts in subdirectories named after the controller
* - noRender - flag indicating whether or not to autorender postDispatch()
* - responseSegment - which named response segment to render a view script to
* - scriptAction - what action script to render
* - viewBasePathSpec - specification to use for determining view base path
* - viewScriptPathSpec - specification to use for determining view script paths
* - viewScriptPathNoControllerSpec - specification to use for determining view script paths when noController flag is set
* - viewSuffix - what view script filename suffix to use
*
* @param string $path
* @param string $prefix
* @param array $options
* @throws Zend_Controller_Action_Exception
* @return void
*/
public function initView($path = null, $prefix = null, array $options = array())
{
$this->setView($this->getServiceLocator()->get('View'));
parent::initView($path, $prefix, $options);
}