mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Renamed domain FixtureManagement to Fixture
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\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
|
||||
{
|
||||
/**
|
||||
* @var string a human readable name
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getName()
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name ?? self::getSlug();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
{
|
||||
$className = get_called_class();
|
||||
$exploded = explode('\\', $className);
|
||||
$shortname = $exploded[count($exploded) - 1];
|
||||
$key = str_replace('FixtureSource', '', $shortname);
|
||||
$lower = strtolower($key);
|
||||
|
||||
return $lower;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\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;
|
||||
|
||||
/**
|
||||
* @see https://fontawesome.com
|
||||
*
|
||||
* @return string|null a fontawesome css class
|
||||
*/
|
||||
public static function getIcon(): string;
|
||||
|
||||
/**
|
||||
* @return string A human readable name, if defined, otherwise a slug
|
||||
*/
|
||||
public function getName(): string;
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Complex\UserSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* This class containes the guest user.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class GuestUserFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'guest user';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$userSource = new UserSource();
|
||||
$userSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRights($userSource);
|
||||
|
||||
return $userSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-user';
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class HelpFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$helpSource = new TextSource();
|
||||
$helpSource->setText('See https://github.com/KevinFrantz/infinito/issues.');
|
||||
$helpSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRights($helpSource);
|
||||
|
||||
return $helpSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-question';
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class HomepageFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$homepage = new TextSource();
|
||||
$homepage->setText('Welcome to infinito!');
|
||||
$homepage->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRights($homepage);
|
||||
|
||||
return $homepage;
|
||||
}
|
||||
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-home';
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$impressumSource = new TextSource();
|
||||
$impressumSource->setText('Example Impressum');
|
||||
$impressumSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRights($impressumSource);
|
||||
|
||||
return $impressumSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-address-card';
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Fixture\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class InformationFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$informationSource = new TextSource();
|
||||
$informationSource->setText('See https://github.com/KevinFrantz/infinito/issues.');
|
||||
$informationSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRights($informationSource);
|
||||
|
||||
return $informationSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-info';
|
||||
}
|
||||
}
|
@@ -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