mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
add new fxtures
This commit is contained in:
57
lib/conf.d/PhraseaFixture/Story/LoadOneStory.php
Normal file
57
lib/conf.d/PhraseaFixture/Story/LoadOneStory.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @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($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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhraseaFixture\ValidationParticipant;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class LoadOneParticipant extends \PhraseaFixture\AbstractWZ implements FixtureInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Entities\ValidationParticipant
|
||||||
|
*/
|
||||||
|
public $validationParticipant;
|
||||||
|
|
||||||
|
public function load($manager)
|
||||||
|
{
|
||||||
|
$validationParticipant = new \Entities\ValidationParticipant();
|
||||||
|
|
||||||
|
if (null === $this->user)
|
||||||
|
{
|
||||||
|
throw new \LogicException('Fill a user to store a new validation Session');
|
||||||
|
}
|
||||||
|
$validationParticipant->setParticipant($this->user);
|
||||||
|
|
||||||
|
$validationParticipant->setSession(
|
||||||
|
$this->getReference('one-validation-session')
|
||||||
|
);
|
||||||
|
|
||||||
|
$manager->persist($validationParticipant);
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
$this->validationParticipant = $validationParticipant;
|
||||||
|
|
||||||
|
$this->addReference('one-validation-participant', $validationParticipant);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhraseaFixture\ValidationParticipant;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class LoadParticipantWithSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Entities\ValidationParticipant
|
||||||
|
*/
|
||||||
|
public $validationParticipant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Entities\ValidationSession
|
||||||
|
*/
|
||||||
|
private $session;
|
||||||
|
|
||||||
|
public function load($manager)
|
||||||
|
{
|
||||||
|
$validationParticipant = new \Entities\ValidationParticipant();
|
||||||
|
|
||||||
|
if (null === $this->user)
|
||||||
|
{
|
||||||
|
throw new \LogicException('Fill a user to store a new validation Session');
|
||||||
|
}
|
||||||
|
$validationParticipant->setParticipant($this->user);
|
||||||
|
|
||||||
|
if (null === $this->session)
|
||||||
|
{
|
||||||
|
throw new \LogicException('Attach a session to the current participant');
|
||||||
|
}
|
||||||
|
$validationParticipant->setSession($this->session);
|
||||||
|
|
||||||
|
$manager->persist($validationParticipant);
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
$this->validationParticipant = $validationParticipant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSession(\Entities\ValidationSession $session)
|
||||||
|
{
|
||||||
|
$this->session = $session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhraseaFixture\ValidationSession;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class LoadOneValidationSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Entities\ValidationSession
|
||||||
|
*/
|
||||||
|
public $validationSession;
|
||||||
|
|
||||||
|
public function load($manager)
|
||||||
|
{
|
||||||
|
$validationSession = new \Entities\ValidationSession();
|
||||||
|
|
||||||
|
$validationSession->setBasket(
|
||||||
|
$this->getReference('one-basket') // load the one-basket stored reference
|
||||||
|
);
|
||||||
|
|
||||||
|
$validationSession->setDescription('Une description au hasard');
|
||||||
|
$validationSession->setName('Un nom de validation');
|
||||||
|
|
||||||
|
$expires = new \DateTime();
|
||||||
|
$expires->modify('+1 week');
|
||||||
|
$validationSession->setExpires($expires);
|
||||||
|
|
||||||
|
if (null === $this->user)
|
||||||
|
{
|
||||||
|
throw new \LogicException('Fill a user to store a new validation Session');
|
||||||
|
}
|
||||||
|
$validationSession->setInitiator($this->user);
|
||||||
|
|
||||||
|
$manager->persist($validationSession);
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
$this->validationSession = $validationSession;
|
||||||
|
|
||||||
|
$this->addReference('one-validation-session', $validationSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user