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

        <bdo id='ENdQj'></bdo><ul id='ENdQj'></ul>
    1. <small id='ENdQj'></small><noframes id='ENdQj'>

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

      在zend框架中调用其他控制器的成员函数?

      Calling member function of other controller in zend framework?(在zend框架中调用其他控制器的成员函数?)
    4. <i id='mMWHE'><tr id='mMWHE'><dt id='mMWHE'><q id='mMWHE'><span id='mMWHE'><b id='mMWHE'><form id='mMWHE'><ins id='mMWHE'></ins><ul id='mMWHE'></ul><sub id='mMWHE'></sub></form><legend id='mMWHE'></legend><bdo id='mMWHE'><pre id='mMWHE'><center id='mMWHE'></center></pre></bdo></b><th id='mMWHE'></th></span></q></dt></tr></i><div id='mMWHE'><tfoot id='mMWHE'></tfoot><dl id='mMWHE'><fieldset id='mMWHE'></fieldset></dl></div>
      <tfoot id='mMWHE'></tfoot>
        <tbody id='mMWHE'></tbody>
        <legend id='mMWHE'><style id='mMWHE'><dir id='mMWHE'><q id='mMWHE'></q></dir></style></legend>

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

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

              • 本文介绍了在zend框架中调用其他控制器的成员函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以在zend框架中调用另一个控制器的成员函数,如果是,那么如何?

                Is it possible to call the member function of another controller in zend framework, if yes then how?

                <?php
                class FirstController extends Zend_Controller_Action {
                    public function indexAction() {
                         // general action 
                    }   
                
                    public function memberFunction() {
                         // a resuable function
                    }
                }
                

                这是另一个控制器

                <?php
                class SecondController extends Zend_Controller_Action {
                    public indexAction() {
                         // here i need to call memberFunction() of FirstController
                    }
                }
                

                请解释我如何从第二个控制器访问 memberFunction().

                Please explain how i can access memberFunction() from second controller.

                更好的想法是定义一个 AppController 并使所有常用控制器扩展 AppController,从而进一步扩展 Zend_Controller_Action.

                Better idea is to define a AppController and make all usual controllers to extend AppController which further extends Zend_Controller_Action.

                class AppController extends Zend_Controller_Action {
                    public function memberFunction() {
                         // a resuable function
                    }
                }
                
                class FirstController extends AppController {
                    public function indexAction() {
                         // call function from any child class
                         $this->memberFunction();
                    } 
                }
                

                现在 memberFunction 可以从扩展 AppController 的控制器调用,作为简单继承的规则.

                Now memberFunction can be invoked from controllers extending AppController as a rule of simple inheritance.

                推荐答案

                控制器并非旨在以这种方式使用.如果您想在当前控制器之后执行另一个控制器的动作,请使用_forward()方法:

                Controllers aren't designed to be used in that way. If you want to execute an action of the other controller after your current controller, use the _forward() method:

                // Invokes SecondController::otherActionAction() after the current action has been finished.
                $this->_forward('other-action', 'second');
                

                请注意,这只适用于操作方法(memberAction"),不适用于任意成员函数!

                Note that this only works for action methods ("memberAction"), not arbitrary member functions!

                如果 SecondController::memberFunction() 做了一些跨多个控制器需要的事情,把代码放在一个动作助手或库类中,这样两个控制器就可以访问共享的功能而不必依赖互相依赖.

                If SecondController::memberFunction() does something that is needed across multiple controllers, put that code in a action helper or library class, so that both controllers can access the shared functionality without having to depend on each other.

                这篇关于在zend框架中调用其他控制器的成员函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <legend id='5aCoB'><style id='5aCoB'><dir id='5aCoB'><q id='5aCoB'></q></dir></style></legend>
                <tfoot id='5aCoB'></tfoot>
              • <small id='5aCoB'></small><noframes id='5aCoB'>

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

                        <tbody id='5aCoB'></tbody>