In between commit implementing security layer

This commit is contained in:
Kevin Frantz
2018-09-22 02:12:03 +02:00
parent bbcf369347
commit d255623f85
8 changed files with 129 additions and 38 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace Creator\Factory;
use App\Entity\SourceInterface;
/**
* @author kevinfrantz
*/
class AbstractSourceFactory
{
/**
* @var SourceInterface
*/
protected $source;
public function __construct(SourceInterface $source)
{
$this->source = $source;
}
protected function getSourceClassShortName(): string
{
$reflection = new \ReflectionClass($this->source);
return $reflection->getShortName();
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Creator\Factory\Facade\Security;
use App\Structur\Facade\Security\Source\interfaces\SourceFacadeInterface;
/**
* @author kevinfrantz
*/
final class SourceFacadeFactory
{
public function getSourceFacade(): SourceFacadeInterface
{
$className = $this->getSourceFacadeClassName();
return new $className();
}
private function getSourceFacadeClassName(): string
{
return 'App\Structur\Facade\Security\Source\\'.$this->getSourceFacadeClassName().'Facade';
}
}

View File

@@ -2,25 +2,15 @@
namespace App\Creator\Factory\Form\Source;
use App\Entity\SourceInterface;
use Creator\Factory\AbstractSourceFactory;
/**
* @author kevinfrantz
*/
class SourceFormFactory
final class SourceFormFactory extends AbstractSourceFactory
{
const FORM_NAMESPACE = 'App\Form\\';
/**
* @var SourceInterface
*/
private $source;
public function __construct(SourceInterface $source)
{
$this->source = $source;
}
public function getNamespace(): string
{
return self::FORM_NAMESPACE.$this->getName();
@@ -28,8 +18,6 @@ class SourceFormFactory
protected function getName(): string
{
$reflectionClass = new \ReflectionClass($this->source);
return $reflectionClass->getShortName().'Type';
return $this->getSourceClassShortName().'Type';
}
}

View File

@@ -4,21 +4,17 @@ namespace App\Creator\Factory\Template\Source;
use App\Entity\SourceInterface;
use Symfony\Component\HttpFoundation\Request;
use Creator\Factory\AbstractSourceFactory;
/**
* @author kevinfrantz
*/
class SourceTemplateFactory
class SourceTemplateFactory extends AbstractSourceFactory
{
const SOURCE_TEMPLATE_ROOT = 'source';
const VIEW_FOLDER = 'view';
/**
* @var SourceInterface
*/
protected $source;
/**
* @var Request
*/
@@ -29,7 +25,7 @@ class SourceTemplateFactory
*/
public function __construct(SourceInterface $source, Request $request)
{
$this->source = $source;
parent::__construct($source);
$this->request = $request;
}
@@ -40,9 +36,7 @@ class SourceTemplateFactory
protected function generateName(): string
{
$reflection = new \ReflectionClass($this->source);
$shortName = $reflection->getShortName();
$lowerName = strtolower($shortName);
$lowerName = strtolower($this->getSourceClassShortName());
return str_replace('source', '', $lowerName);
}

View File

@@ -5,7 +5,7 @@ namespace App\Creator\Factory\Template\Source;
/**
* @author kevinfrantz
*/
class SourceTemplateFormFactory extends SourceTemplateFactory
final class SourceTemplateFormFactory extends SourceTemplateFactory
{
const FORM_FOLDER = 'form';