本文整理汇总了PHP中Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec方法的具体用法?PHP Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec怎么用?PHP Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Action_Helper_ViewRenderer
的用法示例。
在下文中一共展示了Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getViewRenderer
/**
* Retrieves the view renderer object
*
* @return Zend_Controller_Action_Helper_ViewRenderer|null
* @throws Glitch_Application_Resource_Exception
*/
public function getViewRenderer()
{
if (null === $this->_viewRenderer) {
// Pull in the front controller; bootstrap first if necessary
$this->_bootstrap->bootstrap('FrontController');
$front = $this->_bootstrap->getResource('FrontController');
// Ignore if no view renderer is to be used
if ($front->getParam('noViewRenderer')) {
return null;
}
// Get existing renderer, if any, or create a new one
$this->_viewRenderer = Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer') ? Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer') : new $this->_className(null, $this->getOptions());
// Dynamic class loading; perform sanity check
if (!$this->_viewRenderer instanceof Zend_Controller_Action_Helper_ViewRenderer) {
throw new Glitch_Application_Resource_Exception('Class is not a valid view renderer instance');
}
// Register the view as the default view for handling view scripts
$this->_bootstrap->bootstrap('View');
$view = $this->_bootstrap->getResource('View');
$this->_viewRenderer->setView($view);
// It is paramount to set this base path spec: ZF otherwise uses its own
// spec, causing it to create a path to a conventional ZF-style directory
$this->_viewRenderer->setViewBasePathSpec(':module/' . Glitch_View::PATH_VIEW);
// Set empty inflector settings: all path translations are handled by the custom dispatcher
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array(), ':controller' => array(), ':action' => array()));
$this->_viewRenderer->setInflector($inflector, true);
if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::addHelper($this->_viewRenderer);
}
}
return $this->_viewRenderer;
}
示例2: 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');
}
示例3: _initView
/**
* ブートストラップ
*
* @return void
*/
protected function _initView()
{
/*
* Zend_Controller_Action_Helper_ViewRendererオブジェクトに
* Zend_View_Smartyクラスを登録
*/
$view = new Zend_View_Smarty(TEMPLATES_PATH, array('compile_dir' => SMARTY_COMPILE_PATH, 'cache_dir' => SMARTY_CACHE_PATH));
$render = new Zend_Controller_Action_Helper_ViewRenderer($view);
$render->setViewBasePathSpec(':moduleDir' . ABSOLUTE_VIEWS_TEMPLATE_PATH)->setViewSuffix('tpl');
// ヘルパーブローカにViewRendererヘルパーを登録
Zend_Controller_Action_HelperBroker::addHelper($render);
}
示例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: 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');
}
示例6: 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');
}
示例7: init
/**
*
* @return App_View_Smarty
*/
public function init()
{
$options = $this->getOptions();
//--------------------------------------------
// API処理は除外する
$uri = $_SERVER['REQUEST_URI'];
if (preg_match('@rest/@i', $uri)) {
return;
}
//--------------------------------------------
// Pager
Zend_Paginator::setDefaultScrollingStyle('Sliding');
// View
$view = new App_View_Smarty(null, $options);
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
$templateFileName = '';
// helper
$viewRenderer->setViewBasePathSpec(realpath($options['template_dir']))->setViewScriptPathSpec(':controller/' . $templateFileName . ':action.:suffix')->setViewScriptPathNoControllerSpec($templateFileName . ':action.:suffix')->setViewSuffix($options['suffix']);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
示例8: _initialize
/**
* Initialize the paths, the config values and all the render stuff.
*
* @return void
*/
public function _initialize()
{
// Report all PHP errors
error_reporting(-1);
define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
if (!defined('PHPR_CONFIG_FILE')) {
define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.php');
}
set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
require_once 'Phprojekt/Loader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
// Read the config file, but only the production setting
try {
$this->_config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
} catch (Zend_Config_Exception $error) {
$response = new Zend_Controller_Request_Http();
$webPath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
header("Location: " . $webPath . "setup.php");
die('You need the file configuration.php to continue. Have you tried the <a href="' . $webPath . 'setup.php">setup</a> routine?' . "\n" . '<br />Original error: ' . $error->getMessage());
}
// Set webpath, tmpPath and applicationPath
if (empty($this->_config->webpath)) {
$response = new Zend_Controller_Request_Http();
$this->_config->webpath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
}
define('PHPR_ROOT_WEB_PATH', $this->_config->webpath . 'index.php/');
define('PHPR_TEMP_PATH', $this->_config->tmpPath);
define('PHPR_USER_CORE_PATH', $this->_config->applicationPath);
set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . PHPR_USER_CORE_PATH . PATH_SEPARATOR . get_include_path());
// Set the timezone to UTC
date_default_timezone_set('UTC');
// Start zend session to handle all session stuff
try {
Zend_Session::start();
} catch (Zend_Session_Exception $error) {
Zend_Session::writeClose();
Zend_Session::start();
Zend_Session::regenerateId();
error_log($error);
}
// Set a metadata cache and clean it
$frontendOptions = array('automatic_serialization' => true);
$backendOptions = array('cache_dir' => PHPR_TEMP_PATH . 'zendCache' . DIRECTORY_SEPARATOR);
try {
$this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
} catch (Exception $error) {
die("The directory " . PHPR_TEMP_PATH . "zendCache do not exists or not have write access.");
}
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
// Use for Debug only
//Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
// Check Logs
$this->getLog();
$missingRequirements = array();
// The following extensions are either needed by components of the Zend Framework that are used
// or by P6 components itself.
$extensionsNeeded = array('mbstring', 'iconv', 'ctype', 'gd', 'pcre', 'pdo', 'Reflection', 'session', 'SPL', 'zlib');
// These settings need to be properly configured by the admin
$settingsNeeded = array('magic_quotes_gpc' => 0, 'magic_quotes_runtime' => 0, 'magic_quotes_sybase' => 0);
// Check the PHP version
$requiredPhpVersion = "5.2.4";
if (version_compare(phpversion(), $requiredPhpVersion, '<')) {
// This is a requirement of the Zend Framework
$missingRequirements[] = "- PHP Version '" . $requiredPhpVersion . "' or newer";
}
foreach ($extensionsNeeded as $extension) {
if (!extension_loaded($extension)) {
$missingRequirements[] = "- The '" . $extension . "' extension must be enabled.";
}
}
// Check pdo library
$mysql = extension_loaded('pdo_mysql');
$sqlite = extension_loaded('pdo_sqlite2');
$pgsql = extension_loaded('pdo_pgsql');
if (!$mysql && !$sqlite && !$pgsql) {
$missingRequirements[] = "- You need one of these PDO extensions: pdo_mysql, pdo_pgsql or pdo_sqlite";
}
foreach ($settingsNeeded as $conf => $value) {
if (ini_get($conf) != $value) {
$missingRequirements[] = "- The php.ini setting of '" . $conf . "' has to be '" . $value . "'.";
}
}
if (!empty($missingRequirements)) {
$message = "Your PHP does not meet the requirements needed for P6.<br />" . implode("<br />", $missingRequirements);
die($message);
}
$helperPaths = $this->_getHelperPaths();
$view = $this->_setView($helperPaths);
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(':moduleDir/Views');
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
//.........这里部分代码省略.........
示例9: __construct
/**
* Init the front for test it
*/
public function __construct()
{
$this->request = new Zend_Controller_Request_Http();
$this->response = new Zend_Controller_Response_Http();
$this->config = Phprojekt::getInstance()->getConfig();
$this->config->language = "en";
$this->request->setModuleName('Default');
$this->request->setActionName('index');
// Languages Set
Zend_Loader::loadClass('Phprojekt_Language', PHPR_LIBRARY_PATH);
$cache = Phprojekt::getInstance()->getCache();
if (!($translate = $cache->load('Phprojekt_getTranslate_en'))) {
$translate = new Phprojekt_Language('en');
$cache->save($translate, 'Phprojekt_getTranslate_en', array('Language'));
}
Zend_Registry::set('translate', $translate);
$view = new Zend_View();
$view->addScriptPath(PHPR_CORE_PATH . '/Default/Views/dojo/');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(':moduleDir/Views');
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/* Front controller stuff */
$this->front = Zend_Controller_Front::getInstance();
$this->front->setDispatcher(new Phprojekt_Dispatcher());
$this->front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler());
$this->front->setDefaultModule('Default');
$moduleDirectories = array();
foreach (scandir(PHPR_CORE_PATH) as $module) {
$dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module;
if (is_dir(!$dir)) {
continue;
}
$helperPath = $dir . DIRECTORY_SEPARATOR . 'Helpers';
if (is_dir($helperPath)) {
$view->addHelperPath($helperPath, $module . '_' . 'Helpers');
Zend_Controller_Action_HelperBroker::addPath($helperPath);
}
$dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'SubModules';
if (is_dir($dir)) {
if ($module != 'Core') {
$moduleDirectories[] = $dir;
} else {
$coreModules = scandir($dir);
foreach ($coreModules as $coreModule) {
$coreDir = $dir . DIRECTORY_SEPARATOR . $coreModule;
if ($coreModule != '.' && $coreModule != '..' && $coreModule != '.svn' && is_dir($coreDir)) {
$moduleDirectories[] = $coreDir;
}
}
}
}
}
Zend_Registry::set('view', $view);
$view->webPath = $this->config->webpath;
$this->front->setModuleControllerDirectoryName('Controllers');
$this->front->addModuleDirectory(PHPR_CORE_PATH);
foreach ($moduleDirectories as $moduleDirectory) {
$this->front->addModuleDirectory($moduleDirectory);
}
$this->front->setParam('useDefaultControllerAlways', true);
$this->front->throwExceptions(true);
}
示例10: testSettingViewBasePathSpec
public function testSettingViewBasePathSpec()
{
$this->helper->setViewBasePathSpec(':moduleDir/views/:controller');
$this->assertEquals(':moduleDir/views/:controller', $this->helper->getViewBasePathSpec());
}
示例11:
set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
require_once 'Phprojekt/Loader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
Phprojekt_Loader::addIncludeDirectory(realpath(PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application'));
ini_set('max_execution_time', 0);
error_reporting(-1);
// Set the timezone to UTC
date_default_timezone_set('UTC');
// Start zend session to handle all session stuff
Zend_Session::start();
$view = new Zend_View();
$view->addScriptPath(PHPR_CORE_PATH . '/Setup/Views/dojo/');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(':moduleDir/Views');
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$plugin = new Zend_Controller_Plugin_ErrorHandler();
$plugin->setErrorHandlerModule('Setup');
$plugin->setErrorHandlerController('Error');
$plugin->setErrorHandlerAction('error');
$front = Zend_Controller_Front::getInstance();
$front->setDispatcher(new Phprojekt_Dispatcher());
$front->registerPlugin($plugin);
$front->setDefaultModule('Setup');
$front->setModuleControllerDirectoryName('Controllers');
$front->addModuleDirectory(PHPR_CORE_PATH);
$front->setParam('useDefaultControllerAlways', true);
try {
Zend_Controller_Front::getInstance()->dispatch();
示例12: _initialize
/**
* Initialize the paths, the config values and all the render stuff.
*
* @return void
*/
public function _initialize()
{
// Report all PHP errors
error_reporting(-1);
define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
if (!defined('PHPR_CONFIG_FILE')) {
define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.php');
}
set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
require_once 'Phprojekt/Loader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
// Read the config file, but only the production setting
try {
$this->_config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
} catch (Zend_Config_Exception $error) {
$response = new Zend_Controller_Request_Http();
$webPath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
header("Location: " . $webPath . "setup.php");
die('You need the file configuration.php to continue. Have you tried the <a href="' . $webPath . 'setup.php">setup</a> routine?' . "\n" . '<br />Original error: ' . $error->getMessage());
}
// Set webpath, tmpPath and applicationPath
if (empty($this->_config->webpath)) {
$response = new Zend_Controller_Request_Http();
$this->_config->webpath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
}
define('PHPR_ROOT_WEB_PATH', $this->_config->webpath . 'index.php/');
define('PHPR_TEMP_PATH', $this->_config->tmpPath);
define('PHPR_USER_CORE_PATH', $this->_config->applicationPath);
set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . PHPR_USER_CORE_PATH . PATH_SEPARATOR . get_include_path());
// Set the timezone to UTC
date_default_timezone_set('UTC');
// Start zend session to handle all session stuff
try {
Zend_Session::start();
} catch (Zend_Session_Exception $error) {
Zend_Session::writeClose();
Zend_Session::start();
Zend_Session::regenerateId();
error_log($error);
}
// Set a metadata cache and clean it
$frontendOptions = array('automatic_serialization' => true);
$backendOptions = array('cache_dir' => PHPR_TEMP_PATH . 'zendCache' . DIRECTORY_SEPARATOR);
try {
$this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
} catch (Exception $error) {
die("The directory " . PHPR_TEMP_PATH . "zendCache do not exists or not have write access.");
}
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
// Use for Debug only
//Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
// Check Logs
$this->getLog();
// Check the server
$checkServer = Phprojekt::checkExtensionsAndSettings();
// Check the PHP version
if (!$checkServer['requirements']['php']['checked']) {
$missingRequirements[] = "- You need the PHP Version '" . $checkServer['requirements']['php']['required'] . "' or newer";
}
// Check required extension
foreach ($checkServer['requirements']['extension'] as $name => $values) {
if (!$values['checked']) {
$missingRequirements[] = "- The '" . $name . "' extension must be enabled.";
}
}
// Check required settings
foreach ($checkServer['requirements']['settings'] as $name => $values) {
if (!$values['checked']) {
$missingRequirements[] = "- The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'.";
}
}
// Show message
if (!empty($missingRequirements)) {
$message = "Your PHP does not meet the requirements needed for P6.<br />" . implode("<br />", $missingRequirements);
die($message);
}
$helperPaths = $this->_getHelperPaths();
$view = $this->_setView($helperPaths);
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(':moduleDir/Views');
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
foreach ($helperPaths as $helperPath) {
Zend_Controller_Action_HelperBroker::addPath($helperPath['directory']);
}
$plugin = new Zend_Controller_Plugin_ErrorHandler();
$plugin->setErrorHandlerModule('Default');
$plugin->setErrorHandlerController('Error');
$plugin->setErrorHandlerAction('error');
$front = Zend_Controller_Front::getInstance();
$front->setDispatcher(new Phprojekt_Dispatcher());
$front->registerPlugin($plugin);
//.........这里部分代码省略.........