1
我想使用Doctrine PHPCR DataFixtures與參考這裏是一個例子。Doctrine PHPCR DataFixtures
<?php
namespace Example\Bundle\CMSBundle\DataFixtures\PHPCR;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Example\Bundle\CMSBundle\Document\Theme;
use PHPCR\Util\NodeHelper;
class LoadThemeData extends AbstractFixture implements OrderedFixtureInterface
{
/**
* {@inheritDoc}
*/
public function load(ObjectManager $dm)
{
NodeHelper::createPath($dm->getPhpcrSession(), '/cms/themes');
$parent = $dm->find(null, '/cms/themes');
$theme = new Theme();
$theme->setTitle('Home');
$theme->setPath('/');
$theme->setParent($parent);
$dm->persist($theme);
$dm->flush();
$this->setReference('theme-default', $theme);
}
/**
* {@inheritDoc}
*/
public function getOrder()
{
return 1; // the order in which fixtures will be loaded
}
}
出現以下錯誤:
php app/console doctrine:phpcr:fixtures:load
Careful, database will be purged. Do you want to continue Y/N ?y
> purging database
> loading [1] Example\Bundle\CMSBundle\DataFixtures\PHPCR\LoadThemeData
PHP Fatal error: Call to undefined method Doctrine\ODM\PHPCR\UnitOfWork::isInIdentityMap() in /Volumes/Project/CMS/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php on line 97
PHP Stack trace:
PHP 1. {main}() /Volumes/Project/CMS/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /Volumes/Project/CMS/app/console:26
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Volumes/Project/CMS/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP 4. Symfony\Component\Console\Application->doRun() /Volumes/Project/CMS/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
PHP 5. Symfony\Component\Console\Application->doRunCommand() /Volumes/Project/CMS/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP 6. Symfony\Component\Console\Command\Command->run() /Volumes/Project/CMS/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:904
PHP 7. Doctrine\Bundle\PHPCRBundle\Command\LoadFixtureCommand->execute() /Volumes/Project/CMS/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
PHP 8. Doctrine\Common\DataFixtures\Executor\PHPCRExecutor->execute() /Volumes/Project/CMS/vendor/doctrine/phpcr-bundle/Doctrine/Bundle/PHPCRBundle/Command/LoadFixtureCommand.php:111
PHP 9. Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() /Volumes/Project/CMS/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/PHPCRExecutor.php:65
PHP 10. Example\Bundle\CMSBundle\DataFixtures\PHPCR\LoadThemeData->load() /Volumes/Project/CMS/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:121
PHP 11. Doctrine\Common\DataFixtures\AbstractFixture->setReference() /Volumes/Project/CMS/src/Example/Bundle/CMSBundle/DataFixtures/PHPCR/LoadThemeData.php:31
PHP 12. Doctrine\Common\DataFixtures\ReferenceRepository->setReference() /Volumes/Project/CMS/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/AbstractFixture.php:60
展望問題的更多的DoctrineFixturesBundle一個位用於ODM和ORM .. 所以,如果你看一下這兩種學說\ ODM \ PHPCR \的UnitOfWork與條令\ ODM \ MongoDB的\的UnitOfWork,他們都有一個$ identityMap變量..
主義\ ODM \ PHPCR \的UnitOfWork缺少isInIdentityMap功能..
有何建議?接下來我應該做什麼?
您是否曾經找到過解決方案? – Matt
不,我還沒有找到一個 – 888
好吧,我結束了注入doctrine_phpcr服務,只是獲得文件的方式。使用那些有序的裝置讓我做我需要的。 – Matt