严格标准:声明:: postDispatch()

时间:2012-01-29 13:08:53

标签: php zend-framework doctrine strict

我想用zf 1.11配置Doctrine 2.2。一切都已完成,但我不知道这个错误是什么:

  

严格的标准:Sc \ Resource \ EntityManagerFront :: postDispatch()的声明应该与D:\ xampp \ htdocs \ sc \ library \ Sc \ Resource \ EntityManagerFront.php中的Zend_Controller_Plugin_Abstract :: postDispatch()的声明兼容第26行

我的代码:

    <?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;
  }
}

2 个答案:

答案 0 :(得分:4)

postDispatch功能的签名是

public function postDispatch(Zend_Controller_Request_Abstract $request)

因此,您必须指定$request参数类型:Zend_Controller_Request_Abstract

答案 1 :(得分:0)

最终解决方案:

<?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;
    }
}