-- Ehask71 <[email protected]> wrote
(on Sunday, 12 July 2009, 07:31 PM -0700):
> As I am always trying to make sure I am getting the most out of ZF. I am
> working on a new personal project and wanted to do it with a skeleton
> produced by Zend_Tool. In my production projects built back at 1.7 and some
> lower. I had a directory App/ inside my library/ folder. It had a
> Controller.php
> 
>     <?php
>     class App_Controller extends Zend_Controller_Action
>     {
>        protected $_redirector;
>        protected $_flashMessenger = null;
> 
>        public function init()
>        {
>           parent::init();
>           $this->_flashMessenger    =
> $this->_helper->getHelper('FlashMessenger');
>           $this->_redirector = $this->_helper->getHelper('Redirector');
>           $this->initView();
>        }
> 
>        protected function flash($message,$to)
>        {
>           $this->_flashMessenger->addMessage($message);
>           $this->_redirector->gotoUrl($to);
>        }
> 
>        protected function setMessages()
>        {
>           $this->view->messages =
> join("",$this->_flashMessenger->getMessages());
>        }
>         public function postDispatch()
>        {
>           $this->setMessages();
>           parent::postDispatch();
>        }
> 
>     }
> 
> This was mainly to handle messages with flashmessenger. Well I thought I
> added everything correctly but my new project Fatal Errors with:
> Fatal error: Call to a member function getMessages() on a non-object in
> /home/swingco/library/App/Controller.php on line 22
> 
> which is the setMessages() function. Did I forget something or do I need to
> do something different to load the view Helper??? This Controller.php is
> still running fine on 10 production sites right now so I know it has to be
> something in my config or Bootstrap

Is your new controller properly calling the parent in its init() method?

    class FooController extends App_Controller
    {
        public function init()
        {
            parent::init();

            // do some more...
        }
    }

If not, that would account for $_flashMessenger being a non-object on
that line, as it would not have been initialized...

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to