Files
Phraseanet/lib/conf.d/PhraseaFixture/Story/LoadOneStory.php
2012-04-26 02:09:59 +02:00

54 lines
1.2 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\Story;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class LoadOneStory extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var \Entities\StoryWZ
*/
public $story;
public function load(ObjectManager $manager)
{
$story = new \Entities\StoryWZ();
if (null === $this->record) {
throw new \LogicException('Fill a record to store a new story');
}
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new story');
}
$story->setRecord($this->record);
$story->setUser($this->user);
$manager->persist($story);
$manager->flush();
$this->story = $story;
$this->addReference('one-story', $story);
}
}