diff --git a/application/src/Controller/ActivationInterface.php b/application/src/Controller/ActivationInterface.php deleted file mode 100644 index 5d9f984..0000000 --- a/application/src/Controller/ActivationInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -getDoctrine() + ->getRepository(AbstractSource::class) + ->find($id); + if (!$source) { + throw $this->createNotFoundException('No source found for id '.$id); + } + $templateGenerator = new TemplateGenerator($source, $request); - public function activate(): Response - { - } - - public function create(): Response - { - } - - public function delete(): Response - { - } - - public function deactivate(): Response - { + return $this->render($templateGenerator->getTemplatePath(), ['source' => $source]); } } diff --git a/application/src/Controller/SourceControllerInterface.php b/application/src/Controller/SourceControllerInterface.php deleted file mode 100644 index afc396a..0000000 --- a/application/src/Controller/SourceControllerInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -add('name', TextType::class); } - + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ diff --git a/application/src/Form/UserSourceType.php b/application/src/Form/UserSourceType.php index 21f0127..578205f 100644 --- a/application/src/Form/UserSourceType.php +++ b/application/src/Form/UserSourceType.php @@ -1,4 +1,5 @@ add('namesource', NameSourceType::class); @@ -17,8 +17,7 @@ class UserSourceType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => User::class + 'data_class' => User::class, ]); } } - diff --git a/application/src/Source/TemplateGenerator.php b/application/src/Source/TemplateGenerator.php new file mode 100644 index 0000000..93af0b6 --- /dev/null +++ b/application/src/Source/TemplateGenerator.php @@ -0,0 +1,50 @@ +source = $source; + $this->request = $request; + $this->format = $this->request->getRequestFormat(); + } + + public function getTemplatePath(): string + { + return self::SOURCE_TEMPLATE_ROOT.'/'.$this->generateName().'.'.$this->format.'.twig'; + } + + private function generateName(): string + { + $reflection = new \ReflectionClass($this->source); + $shortName = $reflection->getShortName(); + $lowerName = strtolower($shortName); + + return str_replace('source', '', $lowerName); + } +} diff --git a/application/templates/base.html.twig b/application/templates/base.html.twig index cf66b92..ca50a29 100644 --- a/application/templates/base.html.twig +++ b/application/templates/base.html.twig @@ -1,7 +1,7 @@