zf2在全局级别查看manmager默认设置

时间:2014-05-20 07:30:41

标签: php zend-framework2

我已经开始使用zf2了。在zf2中,它为模块级别的视图管理器提供设置。等,

  'view_manager' => array(
    'display_not_found_reason' => true,
    'display_exceptions'       => true,
    'doctype'                  => 'HTML5',
    'not_found_template'       => 'error/404',
    'exception_template'       => 'error/index',
    'template_map' => array(
        'layout/layout'           =>APPLICATION_PATH. '/layout/layout.phtml',
        'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
        'error/404'               => __DIR__ . '/../view/error/404.phtml',
        'error/index'             => __DIR__ . '/../view/error/index.phtml',
    ),
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
),

我想在全局级别定义异常处理程序,异常模板,doctype,错误模板。我不想单独为每个模块定义它。

如果有可能,请指导我?或者我该如何设置?

3 个答案:

答案 0 :(得分:1)

这些设置在全球范围内,它们不是特定于模块的。如果您的其他模块没有任何视图,您可以从其配置中省略view_manager部分。

答案 1 :(得分:0)

按照我的检查您无需在所有模块中重新定义所有视图管理器设置。首先定义主模块中的所有设置。其余模块可以只使用以下必需部分来声明模块视图路径。

'view_manager' => array(
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
), 

答案 2 :(得分:0)

这个定义已经是全球性的。但是module.config是唯一可以定义它的地方。甚至没有Module::getViewManagerConfig方法。

您应该选择哪个模块是“主要”,例如Application,并在module.config.php指定此设置。所有模块都可以使用它。