mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 11:17:58 +00:00 
			
		
		
		
	Applied CS fixer
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Controller;
 | 
			
		||||
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
@@ -6,9 +7,7 @@ use FOS\RestBundle\Controller\FOSRestController;
 | 
			
		||||
use Symfony\Component\HttpFoundation\RedirectResponse;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 *        
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractEntityController extends FOSRestController
 | 
			
		||||
{
 | 
			
		||||
@@ -16,13 +15,14 @@ abstract class AbstractEntityController extends FOSRestController
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $entityName;
 | 
			
		||||
    
 | 
			
		||||
    public function __construct(){
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->setEntityName();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    abstract protected function setEntityName():void;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    abstract protected function setEntityName(): void;
 | 
			
		||||
 | 
			
		||||
    protected function loadEntityById(int $id): EntityInterface
 | 
			
		||||
    {
 | 
			
		||||
        $entity = $this->getDoctrine()
 | 
			
		||||
@@ -31,13 +31,14 @@ abstract class AbstractEntityController extends FOSRestController
 | 
			
		||||
        if (!$entity) {
 | 
			
		||||
            throw $this->createNotFoundException('No entity found for id '.$id);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $entity;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    protected function redirectToRouteById(string $route, int $id): RedirectResponse
 | 
			
		||||
    {
 | 
			
		||||
        return $this->redirectToRoute($route, [
 | 
			
		||||
            'id' => $id
 | 
			
		||||
            'id' => $id,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,64 +1,60 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Controller;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Component\HttpFoundation\RedirectResponse;
 | 
			
		||||
use Symfony\Component\Routing\Annotation\Route;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use App\Entity\Meta\Law;
 | 
			
		||||
use App\Entity\Meta\LawInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 *
 | 
			
		||||
 * @todo Implement security!
 | 
			
		||||
 */
 | 
			
		||||
class LawController extends AbstractEntityController
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/law/{id}.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function show(int $id): Response
 | 
			
		||||
    {
 | 
			
		||||
        /**
 | 
			
		||||
         *
 | 
			
		||||
         * @var LawInterface $law
 | 
			
		||||
         * @var LawInterface
 | 
			
		||||
         */
 | 
			
		||||
        $law = $this->loadEntityById($id);
 | 
			
		||||
        $view = $this->view($law, 200)
 | 
			
		||||
            ->setTemplate('law/view/standard.html.twig')
 | 
			
		||||
            ->setTemplateVar('law');
 | 
			
		||||
 | 
			
		||||
        return $this->handleView($view);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/law/{id}/right.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function right(int $id): RedirectResponse
 | 
			
		||||
    {
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @todo Implement function!
 | 
			
		||||
     */
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement function!
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/law/{id}/node.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function node(int $id): RedirectResponse
 | 
			
		||||
    {
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @todo Implement function!
 | 
			
		||||
     */
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement function!
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function setEntityName(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityName = Law::class;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ use App\Entity\Meta\Relation;
 | 
			
		||||
/**
 | 
			
		||||
 * @todo IMPLEMENT SECURITY!
 | 
			
		||||
 * @todo Refactor!
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class NodeController extends AbstractEntityController
 | 
			
		||||
@@ -22,42 +23,46 @@ class NodeController extends AbstractEntityController
 | 
			
		||||
    public function show(Request $request, int $id): Response
 | 
			
		||||
    {
 | 
			
		||||
        /**
 | 
			
		||||
         * @var RelationInterface $node
 | 
			
		||||
         * @var RelationInterface
 | 
			
		||||
         */
 | 
			
		||||
        $relation = $this->loadEntityById($id);
 | 
			
		||||
        $view = $this->view($relation, 200)
 | 
			
		||||
        ->setTemplate('node/view/standard.html.twig')
 | 
			
		||||
        ->setTemplateVar('node');
 | 
			
		||||
 | 
			
		||||
        return $this->handleView($view);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/node/{id}/law.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function law(int $id): RedirectResponse
 | 
			
		||||
    {
 | 
			
		||||
        $lawId = $this->loadEntityById($id)->getLaw()->getId();
 | 
			
		||||
        return $this->redirectToRouteById('app_law_show',$lawId);
 | 
			
		||||
 | 
			
		||||
        return $this->redirectToRouteById('app_law_show', $lawId);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/node/{id}/parents.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function parents(int $id):Response{
 | 
			
		||||
        /**
 | 
			
		||||
    public function parents(int $id): Response
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/node/{id}/childs.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function childs(int $id):Response{
 | 
			
		||||
        /**
 | 
			
		||||
    public function childs(int $id): Response
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    protected function setEntityName(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityName = Relation::class;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,11 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Controller;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use App\Entity\Method;
 | 
			
		||||
use Symfony\Component\Routing\Annotation\Route;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use App\Creator\Factory\Template\Source\SourceTemplateFactory;
 | 
			
		||||
use FOS\RestBundle\Controller\FOSRestController;
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Creator\Factory\Template\Source\SourceTemplateFormFactory;
 | 
			
		||||
use App\Creator\Factory\Form\Source\SourceFormFactory;
 | 
			
		||||
@@ -15,16 +14,13 @@ use App\Entity\Source\AbstractSource;
 | 
			
		||||
use App\Entity\Meta\RelationInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @todo IMPLEMENT SECURITY!
 | 
			
		||||
 *      
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class SourceController extends AbstractEntityController
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/source/{id}.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function show(Request $request, int $id): Response
 | 
			
		||||
@@ -35,12 +31,11 @@ class SourceController extends AbstractEntityController
 | 
			
		||||
        $view = $this->view($source, 200)
 | 
			
		||||
            ->setTemplate((new SourceTemplateFactory($source, $request))->getTemplatePath())
 | 
			
		||||
            ->setTemplateVar('source');
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return $this->handleView($view);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/source/{id}/edit.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function edit(Request $request, int $id): Response
 | 
			
		||||
@@ -52,23 +47,24 @@ class SourceController extends AbstractEntityController
 | 
			
		||||
            $source = $form->getData();
 | 
			
		||||
            $this->saveSource($source);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return $this->render((new SourceTemplateFormFactory($source, $request))->getTemplatePath(), [
 | 
			
		||||
            'form' => $form->createView()
 | 
			
		||||
            'form' => $form->createView(),
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @Route("/source/{id}/node.{_format}", defaults={"_format"="html"})
 | 
			
		||||
     */
 | 
			
		||||
    public function node(int $id): RedirectResponse
 | 
			
		||||
    {
 | 
			
		||||
        $nodeId = $this->loadNodeById($id)->getId();
 | 
			
		||||
        return $this->redirectToRouteById('app_node_show',$nodeId);
 | 
			
		||||
 | 
			
		||||
        return $this->redirectToRouteById('app_node_show', $nodeId);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private function loadNodeById(int $id):RelationInterface{
 | 
			
		||||
 | 
			
		||||
    private function loadNodeById(int $id): RelationInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->loadEntityById($id)->getNode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user