<bdo id='AYazu'></bdo><ul id='AYazu'></ul>

    <legend id='AYazu'><style id='AYazu'><dir id='AYazu'><q id='AYazu'></q></dir></style></legend>
  1. <i id='AYazu'><tr id='AYazu'><dt id='AYazu'><q id='AYazu'><span id='AYazu'><b id='AYazu'><form id='AYazu'><ins id='AYazu'></ins><ul id='AYazu'></ul><sub id='AYazu'></sub></form><legend id='AYazu'></legend><bdo id='AYazu'><pre id='AYazu'><center id='AYazu'></center></pre></bdo></b><th id='AYazu'></th></span></q></dt></tr></i><div id='AYazu'><tfoot id='AYazu'></tfoot><dl id='AYazu'><fieldset id='AYazu'></fieldset></dl></div>

  2. <small id='AYazu'></small><noframes id='AYazu'>

    1. <tfoot id='AYazu'></tfoot>

      如何向 Zend Framework 2 添加自定义视图助手

      时间:2023-05-31
    2. <legend id='dMMWP'><style id='dMMWP'><dir id='dMMWP'><q id='dMMWP'></q></dir></style></legend>
            <tbody id='dMMWP'></tbody>
          <tfoot id='dMMWP'></tfoot>
          • <bdo id='dMMWP'></bdo><ul id='dMMWP'></ul>
                <i id='dMMWP'><tr id='dMMWP'><dt id='dMMWP'><q id='dMMWP'><span id='dMMWP'><b id='dMMWP'><form id='dMMWP'><ins id='dMMWP'></ins><ul id='dMMWP'></ul><sub id='dMMWP'></sub></form><legend id='dMMWP'></legend><bdo id='dMMWP'><pre id='dMMWP'><center id='dMMWP'></center></pre></bdo></b><th id='dMMWP'></th></span></q></dt></tr></i><div id='dMMWP'><tfoot id='dMMWP'></tfoot><dl id='dMMWP'><fieldset id='dMMWP'></fieldset></dl></div>

                <small id='dMMWP'></small><noframes id='dMMWP'>

                本文介绍了如何向 Zend Framework 2 添加自定义视图助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我之前问过这个问题,我在那里得到了很好的答案.但是,这是针对 beta4 的,不再有效.

                I have earlier asked this question, and I got good answers there. However, that was for beta4, and no longer works.

                那么我在哪里以及如何将我自己的视图助手添加到 ZF2?

                So where and how do I add my own view helpers to ZF2?

                推荐答案

                你应该像这样将它们添加到你的 module.config.php 下的 view_helpers 下:

                You should add them to your module.config.php under view_helpers like this:

                'view_manager' => array(
                    'template_path_stack' => array(
                        'ModuleName' => __DIR__ . '/../view',
                    ),
                ),
                
                'view_helpers' => array(
                    'factories' => array(
                        'showmessages' => function($sm) {
                            $helper = new ModuleNameHelperMessageShower();
                            // do stuff with $sm or the $helper
                            return $helper;           
                        },
                    ),
                    'invokables' => array(
                        'selectmenu' => 'ModuleNameHelperSelectMenu',   
                        'prettyurl'  => 'ModuleNameHelperPrettyUrl',
                    ),  
                ),
                

                这里我展示了两种创建助手的方法.如果它们只需要实例化,只需将它们的名称(包括命名空间)添加为 invokables.如果您需要对它们或 ServiceManager 进行处理,请通过 factories 关键字创建它们.

                Here I show two ways of creating the helpers. If all they need to do is to be instantiated, just add their name (including namespace) as invokables. If you need to do stuff with them or the ServiceManager, create them through the factories keyword.

                这篇关于如何向 Zend Framework 2 添加自定义视图助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何删除 Zend 表单元素上的所有 DtDdWrappers 和标签 下一篇:在一行上显示 Zend_Form_Element_Radio

                相关文章

                <tfoot id='YyOwe'></tfoot>

                  <bdo id='YyOwe'></bdo><ul id='YyOwe'></ul>

                <small id='YyOwe'></small><noframes id='YyOwe'>

                <i id='YyOwe'><tr id='YyOwe'><dt id='YyOwe'><q id='YyOwe'><span id='YyOwe'><b id='YyOwe'><form id='YyOwe'><ins id='YyOwe'></ins><ul id='YyOwe'></ul><sub id='YyOwe'></sub></form><legend id='YyOwe'></legend><bdo id='YyOwe'><pre id='YyOwe'><center id='YyOwe'></center></pre></bdo></b><th id='YyOwe'></th></span></q></dt></tr></i><div id='YyOwe'><tfoot id='YyOwe'></tfoot><dl id='YyOwe'><fieldset id='YyOwe'></fieldset></dl></div>

                  <legend id='YyOwe'><style id='YyOwe'><dir id='YyOwe'><q id='YyOwe'></q></dir></style></legend>