@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\File; | |||
use App\Entity\File\File; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\File\FileInterface; | |||
class FileFactory extends AbstractFactory implements FileFactoryInterface | |||
{ | |||
public function create(): FileInterface | |||
{ | |||
$file = new File(); | |||
return $file; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\File; | |||
interface FileFactoryInterface | |||
{ | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Newsletter; | |||
use App\Entity\Newsletter\Newsletter; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
class NewsletterFactory extends AbstractFactory implements NewsletterFactoryInterface | |||
{ | |||
public function create(): NewsletterInterface | |||
{ | |||
$newsletter = new Newsletter(); | |||
return $newsletter; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Newsletter; | |||
interface NewsletterFactoryInterface | |||
{ | |||
} |
@@ -4,10 +4,11 @@ namespace Lc\SovBundle\Factory\Setting; | |||
use App\Entity\Setting\SiteSetting; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Setting\SiteSettingInterface; | |||
class SiteSettingFactory extends AbstractFactory | |||
class SiteSettingFactory extends AbstractFactory implements SiteSettingFactoryInterface | |||
{ | |||
public function create() | |||
public function create(): SiteSettingInterface | |||
{ | |||
$siteSetting = new SiteSetting(); | |||
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Setting; | |||
interface SiteSettingFactoryInterface | |||
{ | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Site; | |||
use App\Entity\Site\News; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Site\NewsInterface; | |||
class NewsFactory extends AbstractFactory implements NewsFactoryInterface | |||
{ | |||
public function create(): NewsInterface | |||
{ | |||
$news = new News(); | |||
return $news; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Site; | |||
interface NewsFactoryInterface | |||
{ | |||
} |
@@ -4,10 +4,11 @@ namespace Lc\SovBundle\Factory\Site; | |||
use App\Entity\Site\Page; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Site\PageInterface; | |||
class PageFactory extends AbstractFactory | |||
class PageFactory extends AbstractFactory implements PageFactoryInterface | |||
{ | |||
public function create() | |||
public function create(): PageInterface | |||
{ | |||
$page = new Page(); | |||
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Site; | |||
interface PageFactoryInterface | |||
{ | |||
} |
@@ -4,10 +4,11 @@ namespace Lc\SovBundle\Factory\Site; | |||
use App\Entity\Site\Site; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Site\SiteInterface; | |||
class SiteFactory extends AbstractFactory | |||
class SiteFactory extends AbstractFactory implements SiteFactoryInterface | |||
{ | |||
public function create() | |||
public function create(): SiteInterface | |||
{ | |||
$site = new Site(); | |||
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\Site; | |||
interface SiteFactoryInterface | |||
{ | |||
} |
@@ -4,6 +4,7 @@ namespace Lc\SovBundle\Factory\Ticket; | |||
use App\Entity\Ticket\Ticket; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
class TicketFactory extends AbstractFactory implements TicketFactoryInterface | |||
{ | |||
@@ -14,7 +15,7 @@ class TicketFactory extends AbstractFactory implements TicketFactoryInterface | |||
$this->ticketMessageFactory = $ticketMessageFactory; | |||
} | |||
public function create() | |||
public function create(): TicketInterface | |||
{ | |||
$ticket = new Ticket(); | |||
@@ -4,10 +4,11 @@ namespace Lc\SovBundle\Factory\Ticket; | |||
use App\Entity\Ticket\TicketMessage; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketMessageInterface; | |||
class TicketMessageFactory extends AbstractFactory implements TicketMessageFactoryInterface | |||
{ | |||
public function create() | |||
public function create(): TicketMessageInterface | |||
{ | |||
$ticketMessage = new TicketMessage(); | |||
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\User; | |||
use App\Entity\User\GroupUser; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||
class GroupUserFactory extends AbstractFactory implements GroupUserFactoryInterface | |||
{ | |||
public function create(): GroupUserInterface | |||
{ | |||
$groupUser = new GroupUser(); | |||
return $groupUser; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\User; | |||
interface GroupUserFactoryInterface | |||
{ | |||
} |
@@ -4,10 +4,11 @@ namespace Lc\SovBundle\Factory\User; | |||
use App\Entity\User\User; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
class UserFactory extends AbstractFactory | |||
{ | |||
public function create() | |||
public function create(): UserInterface | |||
{ | |||
$user = new User(); | |||
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Factory\User; | |||
interface UserFactoryInterface | |||
{ | |||
} |
@@ -0,0 +1,108 @@ | |||
<?php | |||
namespace Lc\SovBundle\Maker; | |||
use Doctrine\Common\Annotations\Annotation; | |||
use Symfony\Bundle\MakerBundle\ConsoleStyle; | |||
use Symfony\Bundle\MakerBundle\DependencyBuilder; | |||
use Symfony\Bundle\MakerBundle\Generator; | |||
use Symfony\Bundle\MakerBundle\InputConfiguration; | |||
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker; | |||
use Symfony\Component\Console\Command\Command; | |||
use Symfony\Component\Console\Input\InputArgument; | |||
use Symfony\Component\Console\Input\InputInterface; | |||
use function Symfony\Component\String\u; | |||
class FactoryMaker extends AbstractMaker | |||
{ | |||
public static function getCommandName(): string | |||
{ | |||
return 'make:factory'; | |||
} | |||
public static function getCommandDescription(): string | |||
{ | |||
return 'Creates a factory'; | |||
} | |||
public function configureCommand(Command $command, InputConfiguration $inputConf) | |||
{ | |||
$command | |||
/*->addArgument( | |||
'factory-class', | |||
InputArgument::OPTIONAL, | |||
'Choose a name for your factory (e.g. <fg=yellow>MyEntityFactory</>)' | |||
)*/ | |||
->addArgument( | |||
'namespace', | |||
InputArgument::OPTIONAL, | |||
'Namespace (e.g. <fg=yellow>Lc\SovBundle\Factory</>)' | |||
) | |||
->addArgument( | |||
'domain', | |||
InputArgument::OPTIONAL, | |||
'Domain (e.g. <fg=yellow>Order</>)' | |||
) | |||
->addArgument( | |||
'entity-class', | |||
InputArgument::OPTIONAL, | |||
'Define the entity (e.g. <fg=yellow>MyEntity</>)' | |||
) | |||
->setHelp(''); | |||
} | |||
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) | |||
{ | |||
$entityDetails = $generator->createClassNameDetails( | |||
$input->getArgument('entity-class'), | |||
'Entity\\', | |||
'' | |||
); | |||
$factoryClass = $input->getArgument('entity-class') . 'Factory'; | |||
$factoryDetails = $generator->createClassNameDetails( | |||
$factoryClass, | |||
'Factory\\', | |||
'' | |||
); | |||
$options = [ | |||
'namespace_path' => $input->getArgument('namespace'), | |||
'domain' => $input->getArgument('domain'), | |||
'entity_class' => $input->getArgument('entity-class'), | |||
'entity' => $entityDetails->getFullName(), | |||
'entity_variable' => '$' . u($input->getArgument('entity-class'))->camel() | |||
]; | |||
$generator->generateController( | |||
$factoryDetails->getFullName(), | |||
__DIR__ . '/../Resources/maker/factory/factory.tpl.php', | |||
$options | |||
); | |||
$interfaceName = $factoryClass . 'Interface'; | |||
$generator->generateFile( | |||
$generator->getRootDirectory() . '/src/Factory/' . $interfaceName . '.php', | |||
__DIR__ . '/../Resources/maker/factory/factory_interface.tpl.php', | |||
[ | |||
'namespace_path' => $input->getArgument('namespace'), | |||
'domain' => $input->getArgument('domain'), | |||
'interface_name' => $interfaceName, | |||
] | |||
); | |||
$generator->writeChanges(); | |||
$this->writeSuccessMessage($io); | |||
$io->text('Next: Open your new factory class and configure it!'); | |||
} | |||
public function configureDependencies(DependencyBuilder $dependencies) | |||
{ | |||
$dependencies->addClassDependency( | |||
Annotation::class, | |||
'doctrine/annotations' | |||
); | |||
} | |||
} |
@@ -25,3 +25,7 @@ services: | |||
arguments: ["@.inner"] | |||
# EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType: | |||
# class: Lc\SovBundle\Form\Type\CrudFormType | |||
Lc\SovBundle\Maker\: | |||
resource: '../../Maker/' | |||
tags: [ 'maker.command' ] |
@@ -0,0 +1,17 @@ | |||
<?= "<?php\n" ?> | |||
namespace <?= $namespace_path; ?>\<?= $domain; ?>; | |||
use App\Entity\<?= $domain; ?>\<?= $entity_class ?>; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class <?= $class_name; ?> extends AbstractFactory implements <?= $class_name; ?>Interface | |||
{ | |||
public function create(): <?= $entity_class ?>Interface | |||
{ | |||
<?= $entity_variable ?> = new <?= $entity_class ?>(); | |||
return <?= $entity_variable ?>; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?= "<?php\n" ?> | |||
namespace <?= $namespace_path; ?>\<?= $domain; ?>; | |||
interface <?= $interface_name; ?> | |||
{ | |||
} |