我有一個Symfony2項目,並且我在Gedmo的Loggable擴展中遇到問題。Symfony2 Gedmo Loggable在同花順呼叫時崩潰
我有的正在建設,並提交正確的形式,通過了驗證,但是當$EntityManager->flush()
被調用到窗體數據添加到數據庫(MySQL的使用Doctrine),我得到如下:
FatalErrorException: Error: Call to undefined method Path\To\My\Entity\Class::setAction()
in /path/to/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/LoggableListener.php line 225
at ErrorHandler->handleFatal() in /path/to/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php line 0
at LoggableListener->createLogEntry() in /path/to/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/LoggableListener.php line 188
at LoggableListener->onFlush() in /path/to/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 61
at ContainerAwareEventManager->dispatchEvent() in /path/to/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 306
at UnitOfWork->commit() in /path/to/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 355
at EntityManager->flush() in /Path/To/My/Bundle/Controller.php line 364
at Controller->addEntityAction() in /Path/To/app/bootstrap.php.cache line 2891
at ??call_user_func_array() in /Path/To/app/bootstrap.php.cache line 2891
at HttpKernel->handleRaw() in /Path/To/app/bootstrap.php.cache line 2865
at HttpKernel->handle() in /Path/To/app/bootstrap.php.cache line 2994
at ContainerAwareHttpKernel->handle() in /Path/To/app/bootstrap.php.cache line 2274
at Kernel->handle() in /Path/To/web/app_dev.php line 28
at ??{main}() in /Path/To/web/app_dev.php line 0
LoggableListner.php線188是:
foreach ($ea->getScheduledObjectInsertions($uow) as $object) {
$this->createLogEntry(self::ACTION_CREATE, $object, $ea);
}
並在線路188圍繞foreach
全功能是:
public function onFlush(EventArgs $eventArgs)
{
$ea = $this->getEventAdapter($eventArgs);
$om = $ea->getObjectManager();
$uow = $om->getUnitOfWork();
foreach ($ea->getScheduledObjectInsertions($uow) as $object) {
$this->createLogEntry(self::ACTION_CREATE, $object, $ea);
}
foreach ($ea->getScheduledObjectUpdates($uow) as $object) {
$this->createLogEntry(self::ACTION_UPDATE, $object, $ea);
}
foreach ($ea->getScheduledObjectDeletions($uow) as $object) {
$this->createLogEntry(self::ACTION_REMOVE, $object, $ea);
}
}
LoggableListner.php行225:
/** @var \Gedmo\Loggable\Entity\LogEntry $logEntry */
$logEntry = $logEntryMeta->newInstance();
我的實體具有標準的Symfony2註解可記錄的,即:
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @Gedmo\Loggable(logEntryClass="My\Bundles\ThisBundle\ThisEntity")
*/
/**
* @ORM\Column(type="string", length=30, nullable=false)
* @Assert\Length(max=30)
* @Gedmo\Versioned
*/
protected $name;
而且我不知道那裏的setAction()
電話的來源。沒有什麼在我的課名爲「行動」並沒有函數或方法,如getAction()
,addAction()
,removeAction()
等(也不應該有,從我的理解。)
感謝任何的洞察力和幫助!
如果有人有任何問題,甚至會提出疑難解答建議! – 2014-11-25 15:59:29