ZF-98: Messages beetwen actions

Issue Type: New Feature Created: 2006-06-21T20:06:10.000+0000 Last Updated: 2009-04-25T20:28:14.000+0000 Status: Closed Fix version(s): Reporter: Daniel Salvi Wunderlich (daniel_s) Assignee: Mike Naberezny (mike) Tags: - Zend_Controller

Related issues: Attachments:


I was wondering about the Controller/Actions loop in Front Controller, and I think that can be useful an embedded messenger subsystem, toward to improve the communication beetwen actions - for example (in the real world) some use case actions.

Actually this can be done by singleton register method (Zend::register and Zend::registry), registering a class to restore previous messages (errors, informations, confirmations, ...).

By doing this, the message can be raised anywhere during the action:

<pre class="highlight">
$this->raiseMessage(' The message itself ', ActionMessage::ERROR_MESSAGE);

I've coded a simple class to get the idea (and maybe for snippet code):

<pre class="highlight">
 * Class for Handling Messages beetwen actions
 * @copyright  Copyright (c) 2006
 * @license    GPL
class ActionMessage {
    private $messages = array();
    private $errors = array();
    private $confirmations = array();
    const ERROR = "error"; 
    const CONFIRMATION = "confirmation"; 
    const MESSAGE = "message"; 
    public function appendTo($msg, $type = self::MESSAGE) {
        if ($type == self::ERROR) {
            $this->errors[]['msg'] = $msg ;
        else if ($type == self::CONFIRMATION) {
            $this->confirmations[]['msg'] = $msg ;
        else if ($type == self::MESSAGE) {
            $this->messages[]['msg'] = $msg ;
    public function haveMessagesAt($type = self::MESSAGE) {
        if ($type == self::ERROR) {
            return (count($this->errors) > 0) ? true : false ;
        else if ($type == self::CONFIRMATION) {
            return (count($this->confirmations) > 0) ? true : false ;
        else if ($type == self::MESSAGE) {
            return (count($this->messages) > 0) ? true : false ;
    public function getAllErrors() {
        return $this->errors ;
    public function getAllMessages() {
        return $this->messages ;
    public function getAllConfirmations() {
        return $this->confirmations ;
    public function getLastError() {
        return $this->errors[count($this->errors)-1] ;
    public function getLastMessage() {
        return $this->messages[count($this->messages)-1] ;

    public function getLastConfirmation() {
        return $this->confirmations[count($this->confirmations)-1] ;


My best regards...

Daniel S. W.


Posted by Mike Naberezny (mike) on 2006-06-21T21:09:40.000+0000

Messages can be passed by using the $params argument of Zend_Controller_Action::_forward().

Posted by Wil Sinclair (wil) on 2008-12-08T17:04:36.000+0000

Doing bookkeeping. Not sure why this was reopened. Might have been a mistake I made. Please reopen with a comment if it really isn't resolved.

Posted by Matthew Weier O'Phinney (matthew) on 2008-12-08T20:34:42.000+0000

As Mike noted, messages can be passed using the request object parameters during _forward(). Additionally, if you need "flash" messages between requests, we now have the FlashMessenger action helper. Anything beyond this would require a formal proposal at this point.

Posted by Sean P. O. MacCath-Moran (emanaton) on 2009-04-25T20:28:12.000+0000

Greetings All,

FYI, I've created a PriorityMessenger which I believe fulfills the need being addressed here - please check it out and tell me what you think?


Sean P. O. MacCath-Moran <>

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.