Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8053281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:47:33+00:00 2026-06-05T07:47:33+00:00

Hello I am trying to retrieve the values ​​returned by a controller action in

  • 0

Hello I am trying to retrieve the values ​​returned by a controller action in my own library abstract in one of the methods of dispatch of Zend Framework, I wonder if this feat possible and if so how do it.

My code is as follows:

IndexController

class IndexController extends My_Controller
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
       // action body
        return 'hello world';
    }


}

My_Controller

abstract class My_Controller extends Zend_Controller_Action
{
    /**
     * Initialize Core_Controller
     * @param Zend_Controller_Request_Abstract $request
     * @param Zend_Controller_Response_Abstract $response
     * @param array $invokeArgs
     */
    public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
    {
        parent::__construct($request, $response, $invokeArgs);
        $this->_helper->viewRenderer->setNoRender();
    }

    public function preDispatch()
    {
        //something here
    }

    public function postDispatch()
    {
        //something here
    }


    public function dispatch()
    {
        //something here
    }
}

I need to get the value of what was returned in the controllador in this library in order to transform it into json and then print to screen.

Thnk

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:47:35+00:00Added an answer on June 5, 2026 at 7:47 am

    In ZF 1 there isn’t a way to get the return value from the controller action. This value is never used or captured by Zend Framework itself.

    Take a look at Zend/Controller/Action.php line 516 (ZF 1.11.11) and this is the point where ZF calls your controller action, and the return value is not captured or used.

    public function dispatch($action)
    {
        // Notify helpers of action preDispatch state
        $this->_helper->notifyPreDispatch();
    
        $this->preDispatch();
        if ($this->getRequest()->isDispatched()) {
            if (null === $this->_classMethods) {
                $this->_classMethods = get_class_methods($this);
            }
    
            // If pre-dispatch hooks introduced a redirect then stop dispatch
            // @see ZF-7496
            if (!($this->getResponse()->isRedirect())) {
                // preDispatch() didn't change the action, so we can continue
                if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
                    if ($this->getInvokeArg('useCaseSensitiveActions')) {
                        trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
                    }
                    $this->$action(); // <--- line 516 - this calls your action
                } else {
                    $this->__call($action, array());
                }
            }
            $this->postDispatch();
        }
    
        // whats actually important here is that this action controller is
        // shutting down, regardless of dispatching; notify the helpers of this
        // state
        $this->_helper->notifyPostDispatch();
    }
    

    As you can see, the value returned by the controller is never used. Also, in ZF2, they are changing the way controller actions work so the return values actually have meaning so you may want to think of a different approach.

    The quickest thing I can think of at the moment would be instead of trying to return a value from the controller, just set a registry value that you can fetch later.

    e.g.

    public function returnAction()
    {
        // ...
    
        Zend_Registry::set('controller_return_value', 'hello world');
    }
    

    and then later, in your plugin or wherever you are trying to get the value:

    try {
        $retval = Zend_Registry::get('controller_return_value');
    } catch (Zend_Exception $ex) {
        $retval = null; // no return value set by controller
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i been trying to get a tokenizer to work using the boost library
Hello I am trying to save a bitmap image in a basic image editor
Hello I'm trying something .. I was reading Jquery traversing documentations some forums, this
Hello I am trying to setup a Padrino project using DataMapper and MySQL on
Hello i'm trying to implement an AsynController, here is my code: [NoCache] public class
Hello I am trying to combine two transparent png-24 images, both size 400width, 150height.
Hello I am trying to get the user profile picture and then merge into
Hello I been trying to figure out how to set up ASP.Net forms authentication
Hello I am trying to build a multi select to populate a many-to-many join
Hello I'm trying to learn ruby blocks. But I have a trouble to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.