Search code examples
phpzend-frameworkdoctrinestrict

Strict standards: Declaration ::postDispatch()


I want to configure Doctrine 2.2 with zf 1.11. Everything is done, but I dont know what this error is about:

Strict standards: Declaration of Sc\Resource\EntityManagerFront::postDispatch() should be compatible with that of Zend_Controller_Plugin_Abstract::postDispatch() in D:\xampp\htdocs\sc\library\Sc\Resource\EntityManagerFront.php on line 26

My code:

    <?php


namespace Sc\Resource;
use Zend_Controller_Plugin_Abstract, Zend_Controller_Front;

class EntityManagerFront extends Zend_Controller_Plugin_Abstract
{

  /**
   * Flush the EntityManager.
   *
   * (non-PHPdoc)
   * @see Zend_Controller_Plugin_Abstract::dispatchLoopShutdown()
   */

  public function postDispatch($request)
  {

    $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
    $em = $bootstrap->getResource('EntityManager');
    $em->flush();

    return $em;
  }
}

Solution

  • final fixed solution :

    <?php
    
    namespace Sc\Resource;
    
    use Zend_Controller_Plugin_Abstract,
        Zend_Controller_Front,
            Zend_Controller_Request_Http,
            Zend_Controller_Request_Abstract;
    
    
    class EntityManagerFront extends Zend_Controller_Plugin_Abstract {
        /**
         * Flush the EntityManager.
         *
         * (non-PHPdoc)
         * @see Zend_Controller_Plugin_Abstract::dispatchLoopShutdown()
         */
        public function postDispatch(Zend_Controller_Request_Abstract $request) {
    
            $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
            $em = $bootstrap->getResource('EntityManager');
            $em->flush();
    
            return $em;
        }
    }