1

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

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

我的代码:

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

2 回答 2

4

postDispatch 函数的签名是

public function postDispatch(Zend_Controller_Request_Abstract $request)

所以你必须指定$request参数类型:Zend_Controller_Request_Abstract

于 2012-01-29T14:42:51.693 回答
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;
    }
}
于 2012-01-30T09:41:30.557 回答