Merged Pull Request Introduce code formatting with PHP-CS-Fixer

This commit is contained in:
Kevin Frantz
2018-09-13 03:29:34 +02:00
42 changed files with 553 additions and 299 deletions

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
interface ActivationInterface
{
public function deactivate():Response;
public function activate():Response;
}
public function deactivate(): Response;
public function activate(): Response;
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
interface CreationInterface
{
public function create():Response;
public function delete():Response;
}
public function create(): Response;
public function delete(): Response;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -6,9 +7,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
class DefaultController extends AbstractController
{
@@ -17,15 +16,14 @@ class DefaultController extends AbstractController
*/
public function imprint(): Response
{
return $this->render("standard/imprint.html.twig");
return $this->render('standard/imprint.html.twig');
}
/**
* @Route("/", name="homepage")
*/
public function homepage(): Response
{
return $this->render("standard/homepage.html.twig");
return $this->render('standard/homepage.html.twig');
}
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
interface ModificationInterface
{
public function modify(int $id):Response;
public function modify(int $id): Response;
}

View File

@@ -1,32 +1,35 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
class SourceController implements SourceControllerInterface
{
public function modify(int $id): Response
{}
{
}
public function show(int $id): Response
{}
{
}
public function activate(): Response
{}
{
}
public function create(): Response
{}
{
}
public function delete(): Response
{}
{
}
public function deactivate(): Response
{}
{
}
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @author kevinfrantz
*
*/
interface SourceControllerInterface extends CreationInterface, ActivationInterface, ModificationInterface
{
public function show(int $id):Response;
public function show(int $id): Response;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\IdAttribut;
@@ -6,22 +7,20 @@ use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @author kevinfrantz
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
* @ORM\Entity
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"user" = "User"})
* @ORM\DiscriminatorMap({"user" = "User"})
*/
abstract class AbstractSource implements SourceInterface
{
{
use IdAttribut,NodeAttribut;
/**
*
* @var ConfigurationInterface
*/
protected $configuration;
}
}

View File

@@ -1,36 +1,35 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait ChildsAttribut {
trait ChildsAttribut
{
/**
* Many Nodes have many childs
* Many Nodes have many childs.
*
* @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_childs",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* )
*
* @var ArrayCollection|NodeInterface[]
*/
protected $childs;
public function getChilds(): ArrayCollection
{
return $this->getChilds();
}
public function setChilds(ArrayCollection $childs): void
{
$this->childs = $childs;
}
}

View File

@@ -1,15 +1,15 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ChildsAttributeInterface
{
public function setChilds(ArrayCollection $childs):void;
public function getChilds():ArrayCollection;
}
public function setChilds(ArrayCollection $childs): void;
public function getChilds(): ArrayCollection;
}

View File

@@ -1,29 +1,28 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @author kevinfrantz
*
*/
trait IdAttribut {
trait IdAttribut
{
/**
* @ORM\Id()
* @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO")
*/
protected $id;
public function setId(int $id): void
{
$this->id = $id;
}
public function getId(): int
{
return $this->id;
}
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
interface IdAttributInterface
{
public function setId(int $id): void;
public function getId(): int;
}

View File

@@ -1,30 +1,28 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait NodeAttribut{
trait NodeAttribut
{
/**
* @var NodeInterface
* @ORM\OneToOne(targetEntity="Node")
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
*/
protected $node;
public function setNode(NodeInterface $node): void
{
$this->node = $node;
}
public function getNode(): NodeInterface
{
return $this->node;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeAttributInterface
{
public function setNode(NodeInterface $node):void;
public function getNode():NodeInterface;
}
public function setNode(NodeInterface $node): void;
public function getNode(): NodeInterface;
}

View File

@@ -1,24 +1,24 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait ParentAttribut {
trait ParentAttribut
{
/**
* Many Nodes have many parents
* Many Nodes have many parents.
*
* @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_parents",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* )
*
* @var ArrayCollection|NodeInterface[]
*/
protected $parents;
@@ -33,4 +33,3 @@ trait ParentAttribut {
$this->parents = $parents;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ParentsAttributInterface
{
public function setParents(ArrayCollection $parents):void;
public function getParents():ArrayCollection;
}
public function setParents(ArrayCollection $parents): void;
public function getParents(): ArrayCollection;
}

View File

@@ -1,24 +1,24 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
trait PasswordAttribut {
trait PasswordAttribut
{
/**
* @ORM\Column(type="string", length=64)
*/
protected $password;
public function getPassword():?string
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password):void{
public function setPassword(string $password): void
{
$this->password = $password;
}
}

View File

@@ -1,18 +1,18 @@
<?php
namespace App\Entity\Attribut;
use Symfony\Component\Validator\Constraints as Assert;
/**
*
* @author kevinfrantz
*
*/
trait PlainPasswordAttribute {
trait PlainPasswordAttribute
{
/**
*
* @Assert\NotBlank()
* @Assert\Length(max=4096)
*
* @var string
*/
private $plainPassword;
@@ -27,4 +27,3 @@ trait PlainPasswordAttribute {
$this->plainPassword = $password;
}
}

View File

@@ -1,27 +1,29 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;
/**
*
* @author kevinfrantz
*
*/
trait SourceAttribut {
trait SourceAttribut
{
/**
* @ORM\OneToOne(targetEntity="AbstractSource")
* @ORM\JoinColumn(name="source_id", referencedColumnName="id")
*
* @var SourceInterface
*/
protected $source;
public function getSource():SourceInterface{
public function getSource(): SourceInterface
{
return $this->source;
}
public function setSource(SourceInterface $source):void{
public function setSource(SourceInterface $source): void
{
$this->source = $source;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;
/**
*
* @author kevinfrantz
*
*/
interface SourceAttributInterface
{
public function getSource():SourceInterface;
public function setSource(SourceInterface $source):void;
}
public function getSource(): SourceInterface;
public function setSource(SourceInterface $source): void;
}

View File

@@ -1,25 +1,26 @@
<?php
namespace App\Entity\Attribut;
/**
* This trait doesn't need an own interface because it's covered by symfony
* This trait doesn't need an own interface because it's covered by symfony.
*
* @author kevinfrantz
*
*/
trait UsernameAttribut{
trait UsernameAttribut
{
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
public function getUsername():?string
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username):void{
public function setUsername(string $username): void
{
$this->username = \trim($username);
}
}

View File

@@ -1,48 +1,48 @@
<?php
namespace App\Entity;
/**
*
* @author kevinfrantz
*
*/
class Configuration implements ConfigurationInterface
{
/**
*
* @var PropertyInterface
*/
protected $read;
/**
*
* @var PropertyInterface
*/
protected $write;
/**
*
* @var PropertyInterface
*/
protected $administrate;
public function setAdministrate(Property $administrate): void
{}
{
}
public function getAdministrate(): Property
{}
{
}
public function setWrite(Property $write): void
{}
{
}
public function getWrite(): Property
{}
{
}
public function setRead(Property $read): void
{}
{
}
public function getRead(): Property
{}
{
}
}

View File

@@ -1,24 +1,23 @@
<?php
namespace App\Entity;
/**
* This class is not a source!
*
* @author kevinfrantz
*
*/
interface ConfigurationInterface
{
public function setRead(Property $read):void;
public function getRead():Property;
public function setWrite(Property $write):void;
public function getWrite():Property;
public function setAdministrate(Property $administrate):void;
public function getAdministrate():Property;
}
public function setRead(Property $read): void;
public function getRead(): Property;
public function setWrite(Property $write): void;
public function getWrite(): Property;
public function setAdministrate(Property $administrate): void;
public function getAdministrate(): Property;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -8,7 +9,6 @@ use App\Entity\Attribut\ParentAttribut;
use App\Entity\Attribut\ChildsAttribut;
/**
*
* @author kevinfrantz
* @ORM\Table(name="node")
* @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
@@ -16,8 +16,7 @@ use App\Entity\Attribut\ChildsAttribut;
class Node implements NodeInterface
{
use IdAttribut,
SourceAttribut,
ParentAttribut,
SourceAttribut,
ParentAttribut,
ChildsAttribut;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\SourceAttributInterface;
@@ -7,10 +8,8 @@ use App\Entity\Attribut\ParentsAttributInterface;
use App\Entity\Attribut\ChildsAttributeInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface,ChildsAttributeInterface
{}
interface NodeInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface
{
}

View File

@@ -1,32 +1,29 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
class Property implements PropertyInterface
{
/**
*
* @var ArrayCollection|NodeInterface[]
*/
protected $whitelist;
/**
*
* @var ArrayCollection|NodeInterface[]
*/
protected $blacklist;
public function getLegitimated(): ArrayCollection
{}
{
}
public function isLegitimated(SourceInterface $source): bool
{}
{
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface PropertyInterface
{
public function isLegitimated(SourceInterface $source):bool;
public function getLegitimated():ArrayCollection;
}
public function isLegitimated(SourceInterface $source): bool;
public function getLegitimated(): ArrayCollection;
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NodeAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
/**
*
* @author kevinfrantz
*
*/
interface SourceInterface extends IdAttributInterface, NodeAttributInterface
{
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -6,7 +7,6 @@ use FOS\UserBundle\Model\User as BaseUser;
use App\Entity\Attribut\NodeAttribut;
/**
*
* @author kevinfrantz
* @ORM\Table(name="source_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
@@ -14,24 +14,24 @@ use App\Entity\Attribut\NodeAttribut;
class User extends BaseUser implements SourceInterface
{
use NodeAttribut;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
/**
* @ORM\Id()
* @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO")
*/
protected $id;
public function setId(int $id): void
{
$this->id = $id;
}
public function getId(): int
{
return $this->id;
@@ -39,8 +39,8 @@ class User extends BaseUser implements SourceInterface
public function __construct()
{
parent::__construct ();
/**
parent::__construct();
/*
* @todo Remove this later
* @var \App\Entity\User $isActive
*/

View File

@@ -10,29 +10,29 @@ use Symfony\Component\HttpFoundation\RequestStack;
class UserMenuEvent extends Event
{
public const EVENT = 'app.menu.topbar.user';
/**
* @var FactoryInterface
*/
private $factory;
/**
* @var ItemInterface
*/
private $item;
/**
* @var RequestStack
*/
private $request;
public function __construct(FactoryInterface $factory, ItemInterface $item, RequestStack $request)
{
$this->factory = $factory;
$this->item = $item;
$this->request = $request;
}
/**
* @return FactoryInterface
*/
@@ -40,7 +40,7 @@ class UserMenuEvent extends Event
{
return $this->factory;
}
/**
* @return ItemInterface
*/
@@ -48,7 +48,7 @@ class UserMenuEvent extends Event
{
return $this->item;
}
/**
* @return RequestStack
*/
@@ -56,4 +56,4 @@ class UserMenuEvent extends Event
{
return $this->request;
}
}
}

View File

@@ -1,11 +1,11 @@
<?php
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
@@ -16,18 +16,18 @@ class UserType extends AbstractType
{
$builder
->add('username', TextType::class)
->add('plainPassword', RepeatedType::class, array(
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
))
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat Password'],
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => User::class,
));
]);
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
// src/Menu/Menu.php
namespace App\Menu;
@@ -11,36 +12,35 @@ use Symfony\Component\HttpFoundation\RequestStack;
class Menu
{
/**
* @var EventDispatcherInterface
*/
private $dispatcher;
/**
* @var FactoryInterface
*/
private $factory;
public function __construct(FactoryInterface $factory, EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
$this->factory = $factory;
}
public function userTopbar(RequestStack $request): ItemInterface
{
$menu = $this->factory->createItem('root', array(
'childrenAttributes' => array(
'class' => 'navbar-nav mr-auto',
),
));
$menu = $this->factory->createItem('root', [
'childrenAttributes' => [
'class' => 'navbar-nav mr-auto',
],
]);
$this->dispatcher->dispatch(
UserMenuEvent::EVENT,
new UserMenuEvent($this->factory, $menu, $request)
);
return $menu;
}
}
}
}

View File

@@ -1,14 +1,12 @@
<?php
namespace App\Repository;
use Doctrine\ORM\EntityRepository;
/**
*
* @author kevinfrantz
*
*/
class UserRepository extends EntityRepository
{
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Subscriber;
use App\Event\Menu\Topbar\UserMenuEvent;
@@ -8,15 +9,12 @@ use Symfony\Component\Translation\TranslatorInterface;
class UserMenuSubscriber implements EventSubscriberInterface
{
/**
*
* @var TokenStorageInterface
*/
private $tokenStorage;
/**
*
* @var TranslatorInterface
*/
private $translator;
@@ -33,61 +31,64 @@ class UserMenuSubscriber implements EventSubscriberInterface
$menu->addChild('start', [
'route' => 'homepage',
'attributes' => [
'icon' => 'fab fa-font-awesome-flag'
'icon' => 'fab fa-font-awesome-flag',
],
]
);
$menu->addChild(
'imprint',
[
'route' => 'imprint',
'attributes' => [
'icon' => 'fas fa-address-card',
],
]
]);
$menu->addChild('imprint', [
'route' => 'imprint',
'attributes' => [
'icon' => 'fas fa-address-card'
]
]);
);
$dropdown = $menu->addChild($this->tokenStorage->getToken()
->getUsername() ?? 'user', [
'attributes' => [
'dropdown' => true,
'icon' => 'fas fa-user'
]
'icon' => 'fas fa-user',
],
]);
if ($this->tokenStorage->getToken()->getRoles()) {
$dropdown->addChild('logout', [
'route' => 'logout',
'attributes' => [
'icon' => 'fas fa-sign-out-alt',
'divider_append' => true
]
'divider_append' => true,
],
]);
$dropdown->addChild('edit profile', [
'route' => 'fos_user_profile_edit',
'attributes' => [
'icon' => 'fas fa-user-edit',
'divider_append' => true
]
'divider_append' => true,
],
]);
} else {
$dropdown->addChild('login', [
'route' => 'fos_user_security_login',
'attributes' => [
'divider_append' => true,
'icon' => 'fas fa-sign-in-alt'
]
'icon' => 'fas fa-sign-in-alt',
],
]);
}
$dropdown->addChild('register', [
'route' => 'fos_user_registration_register',
'attributes' => [
'icon' => 'fas fa-file-signature'
]
'icon' => 'fas fa-file-signature',
],
]);
}
public static function getSubscribedEvents(): array
{
return [
UserMenuEvent::EVENT => 'onUserMenuConfigure'
UserMenuEvent::EVENT => 'onUserMenuConfigure',
];
}
}