mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	implemented sourcemeta and test
This commit is contained in:
		
							
								
								
									
										22
									
								
								application/src/DBAL/Types/TemplateType.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								application/src/DBAL/Types/TemplateType.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\DBAL\Types; | ||||
|  | ||||
| use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType; | ||||
|  | ||||
| /** | ||||
|  * Containes the template types which the system can process. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class TemplateType extends AbstractEnumType | ||||
| { | ||||
|     public const JSON = 'json'; | ||||
|  | ||||
|     public const HTML = 'html'; | ||||
|  | ||||
|     protected static $choices = [ | ||||
|         self::JSON => 'json', | ||||
|         self::HTML => 'html', | ||||
|     ]; | ||||
| } | ||||
| @@ -0,0 +1,8 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\FormManagement; | ||||
|  | ||||
| interface FormMetaInterface | ||||
| { | ||||
|     public function getFormPath(): string; | ||||
| } | ||||
							
								
								
									
										106
									
								
								application/src/Domain/SourceManagement/SourceMeta.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								application/src/Domain/SourceManagement/SourceMeta.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,106 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\SourceManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplateMetaInterface; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Domain\TemplateManagement\TemplateMeta; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class SourceMeta implements SourceMetaInterface | ||||
| { | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $sourceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $interfaceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplateMetaInterface | ||||
|      */ | ||||
|     private $templateMeta; | ||||
|  | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     private $basicPathArray; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $basicName; | ||||
|  | ||||
|     /** | ||||
|      * @var SourceInterface | ||||
|      */ | ||||
|     private $source; | ||||
|  | ||||
|     public function __construct(SourceInterface $source) | ||||
|     { | ||||
|         $this->source = $source; | ||||
|         $this->sourceReflection = new \ReflectionClass($source); | ||||
|         $this->setBasicPathArray(); | ||||
|         $this->setBasicName(); | ||||
|         $this->setInterfaceReflection(); | ||||
|         $this->templateMeta = new TemplateMeta($this); | ||||
|     } | ||||
|  | ||||
|     private function setBasicPathArray(): void | ||||
|     { | ||||
|         $namespace = $this->sourceReflection->getNamespaceName(); | ||||
|         $namespaceWithoutRoot = str_replace('App\\', '', $namespace); | ||||
|         $this->basicPathArray = []; | ||||
|         foreach (explode('\\', $namespaceWithoutRoot) as $element) { | ||||
|             $this->basicPathArray[] = strtolower($element); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function setInterfaceReflection(): void | ||||
|     { | ||||
|         $namespace = str_replace('\Abstract', '\\', $this->sourceReflection->getName()).'Interface'; | ||||
|         $this->interfaceReflection = new \ReflectionClass($namespace); | ||||
|     } | ||||
|  | ||||
|     private function setBasicName(): void | ||||
|     { | ||||
|         $withoutAbstract = str_replace('Abstract', '', $this->sourceReflection->getShortName()); | ||||
|         $withoutSource = str_replace('Source', '', $withoutAbstract); | ||||
|         $this->basicName = strtolower($withoutSource); | ||||
|     } | ||||
|  | ||||
|     public function getBasicPathArray(): array | ||||
|     { | ||||
|         return $this->basicPathArray; | ||||
|     } | ||||
|  | ||||
|     public function getInterfaceReflection(): \ReflectionClass | ||||
|     { | ||||
|         return $this->interfaceReflection; | ||||
|     } | ||||
|  | ||||
|     public function getSourceReflection(): \ReflectionClass | ||||
|     { | ||||
|         return $this->sourceReflection; | ||||
|     } | ||||
|  | ||||
|     public function getTemplateMeta(): TemplateMetaInterface | ||||
|     { | ||||
|         return $this->templateMeta; | ||||
|     } | ||||
|  | ||||
|     public function getBasicName(): string | ||||
|     { | ||||
|         return $this->basicName; | ||||
|     } | ||||
|  | ||||
|     public function getSource(): SourceInterface | ||||
|     { | ||||
|         return $this->source; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\SourceManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplateMetaInterface; | ||||
| use App\Entity\Source\SourceInterface; | ||||
|  | ||||
| /** | ||||
|  * A meta source offers informations, which the system needs to handle the source. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface SourceMetaInterface | ||||
| { | ||||
|     public function getSourceReflection(): \ReflectionClass; | ||||
|  | ||||
|     public function getInterfaceReflection(): \ReflectionClass; | ||||
|  | ||||
|     public function getTemplateMeta(): TemplateMetaInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return array the namespace elements without the root | ||||
|      */ | ||||
|     public function getBasicPathArray(): array; | ||||
|  | ||||
|     /** | ||||
|      * @return string Short class name in lower case without "Abstract" and "Source" | ||||
|      */ | ||||
|     public function getBasicName(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return SourceInterface The source to which the meta object belongs to | ||||
|      */ | ||||
|     public function getSource(): SourceInterface; | ||||
| } | ||||
							
								
								
									
										41
									
								
								application/src/Domain/TemplateManagement/TemplateMeta.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								application/src/Domain/TemplateManagement/TemplateMeta.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| use App\Domain\FormManagement\FormMetaInterface; | ||||
| use App\Domain\SourceManagement\SourceMetaInterface; | ||||
| use App\DBAL\Types\TemplateType; | ||||
|  | ||||
| class TemplateMeta implements TemplateMetaInterface | ||||
| { | ||||
|     /** | ||||
|      * @var TemplateMetaInterface | ||||
|      */ | ||||
|     private $sourceMeta; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $type = TemplateType::HTML; | ||||
|  | ||||
|     public function __construct(SourceMetaInterface $sourceMeta) | ||||
|     { | ||||
|         $this->sourceMeta = $sourceMeta; | ||||
|     } | ||||
|  | ||||
|     public function getFramedTemplatePath(): string | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function getFramelessTemplatePath(): string | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function getFormMeta(): FormMetaInterface | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function setTemplateType(string $type): void | ||||
|     { | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| use App\Domain\FormManagement\FormMetaInterface; | ||||
|  | ||||
| /** | ||||
|  * Manages all informations which are needed to process templates. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface TemplateMetaInterface | ||||
| { | ||||
|     /** | ||||
|      * Sets the template type which should be processed(General html);. | ||||
|      */ | ||||
|     public function setTemplateType(string $type): void; | ||||
|  | ||||
|     /** | ||||
|      * Returns a template inclusiv frame. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getFramedTemplatePath(): string; | ||||
|  | ||||
|     /** | ||||
|      * Returns a template without a frame. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getFramelessTemplatePath(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return FormMetaInterface | ||||
|      */ | ||||
|     public function getFormMeta(): FormMetaInterface; | ||||
| } | ||||
| @@ -10,9 +10,6 @@ use App\Entity\Source\SourceInterface; | ||||
| trait SourceAttribut | ||||
| { | ||||
|     /** | ||||
|      * @ORM\OneToOne(targetEntity="AbstractSource") | ||||
|      * @ORM\JoinColumn(name="source_id", referencedColumnName="id") | ||||
|      * | ||||
|      * @var SourceInterface | ||||
|      */ | ||||
|     protected $source; | ||||
|   | ||||
| @@ -11,6 +11,7 @@ use App\Entity\UserInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated Just exists as a remembering to maybe use the voter for some use cases | ||||
|  * @see https://symfony.com/doc/current/security/voters.html | ||||
|  */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user