2013-03-11 74 views
0

我想了解有关学说活动,但是当我读到the docs,我感到迷惑的第一行:类“eventmanager进行”未找到

$evm = new EventManager(); 

在这里,我得到一个

PHP Fatal error: Class 'EventManager' not found

我该如何解决这个问题?

下面是完整的代码:

use Doctrine\ORM\Tools\Setup; 

require_once("Doctrine/ORM/Tools/Setup.php"); 
Setup::registerAutoloadPEAR(); 

$classLoader = new Doctrine\Common\ClassLoader('Entities', __DIR__); 
$classLoader->register(); 

$paths = array(); 
$isDevMode = true; 
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); 
$dbParams = array("driver" => "pdo_mysql", 
    "host" => variable_get("dbManip_host"), 
    "user" => variable_get("dbManip_user"), 
    "password" => variable_get("dbManip_password"), 
    "dbname" => variable_get("dbManip_dbName"), 
    "charset" => "utf8"); 
global $entityManager_globalObject; 
$entityManager_globalObject = \Doctrine\ORM\EntityManager::create($dbParams, $config); 
$entityManager_globalObject->getConnection()->exec("SET NAMES UTF8"); 

$evm = new EventManager(); 

回答

1

您正在寻找Doctrine\Common\EventManager类。

$evm = new \Doctrine\Common\EventManager(); 

use Doctrine\Common\EventManager; // at the top of your file 

$evm = new EventManager(); 
+0

这是令人惊讶的简单(错误已消失)。为什么他们没有将这些工作代码放在文档中,而不是现在有什么(非工作代码)? – Shawn 2013-03-11 17:10:01

+0

@Shawn可能是受到监督的东西。所有的类型提示都会导致这个类,所以不应该很难发现它应该是什么样子。另外,您可以在http://www.doctrine-project.org/jira/上的问题跟踪器上报告问题,或者通过https://github.com/doctrine/doctrine2/tree/打开对文档的请求。主/文档 – Ocramius 2013-03-11 17:23:31