mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-10-11 10:08:08 +02:00
Implemented FixtureManagement
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
/**
|
||||
* Classes which inhiere from this class and should be loaded by SourceFixtures MUST be declared as final.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractFixtureSource implements FixtureSourceInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Attribut\SlugAttributInterface;
|
||||
|
||||
/**
|
||||
* This interface allows to save the configuration values of an fixture in a class.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface FixtureSourceInterface
|
||||
{
|
||||
/**
|
||||
* @return SourceInterface An source, which can be handled by Doctrine ORM persist
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface;
|
||||
|
||||
/**
|
||||
* It's necessary for tests and to address the object correct.
|
||||
*
|
||||
* @return SlugAttributInterface
|
||||
*/
|
||||
public static function getSlug(): string;
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Source\Complex\UserSource;
|
||||
|
||||
/**
|
||||
* This class containes the guest user.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class GuestUserFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
const SLUG = 'GUEST_USER';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\FixtureManagement\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$userSource = new UserSource();
|
||||
$userSource->setSlug(self::SLUG);
|
||||
|
||||
return $userSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
{
|
||||
return self::SLUG;
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Source\Primitive\Text\TextSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
const SLUG = 'IMPRINT';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\FixtureManagement\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$impressumSource = new TextSource();
|
||||
$impressumSource->setText('Example Impressum');
|
||||
$impressumSource->setSlug(self::SLUG);
|
||||
|
||||
return $impressumSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
{
|
||||
return self::SLUG;
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
# Fixture Sources
|
||||
This folder containes all source class objects which will be load into the database. This structure allows unit tests for the source fixtures.
|
Reference in New Issue
Block a user