mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized ORM-Structure
This commit is contained in:
parent
261b704017
commit
a857f515d3
@ -2,6 +2,8 @@
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\NodeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
@ -10,7 +12,13 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
trait ChildsAttribut {
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
* 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;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\NodeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -11,7 +12,14 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
trait ParentAttribut {
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
* 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;
|
||||
|
||||
|
24
application/src/Entity/Attribut/PasswordAttribut.php
Normal file
24
application/src/Entity/Attribut/PasswordAttribut.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
trait PasswordAttribut {
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
public function getPassword():string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password):void{
|
||||
$this->password = $password;
|
||||
}
|
||||
}
|
||||
|
25
application/src/Entity/Attribut/UsernameAttribut.php
Normal file
25
application/src/Entity/Attribut/UsernameAttribut.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* This trait doesn't need an own interface because it's covered by symfony
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
trait UsernameAttribut{
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=25, unique=true)
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
public function getUsername():string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function setUsernames(string $username):void{
|
||||
$this->username = $username;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use App\Entity\Attribut\SourceAttribut;
|
||||
use App\Entity\Attribut\ParentAttribut;
|
||||
@ -16,28 +15,9 @@ use App\Entity\Attribut\ChildsAttribut;
|
||||
*/
|
||||
class Node implements NodeInterface
|
||||
{
|
||||
use IdAttribut,SourceAttribut, ParentAttribut, ChildsAttribut;
|
||||
|
||||
/**
|
||||
* 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|Node[]
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* 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|Node[]
|
||||
*/
|
||||
protected $childs;
|
||||
use IdAttribut,
|
||||
SourceAttribut,
|
||||
ParentAttribut,
|
||||
ChildsAttribut;
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,19 @@
|
||||
<?php
|
||||
namespace App\Entity;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\UsernameAttribut;
|
||||
use App\Entity\Attribut\PasswordAttribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="source_user")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||
*/
|
||||
class User extends AbstractSource implements UserInterface, \Serializable
|
||||
class User extends AbstractSource implements UserInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="string", length=25, unique=true)
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*/
|
||||
private $password;
|
||||
use UsernameAttribut,PasswordAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=254, unique=true)
|
||||
@ -38,11 +32,6 @@ class User extends AbstractSource implements UserInterface, \Serializable
|
||||
// $this->salt = md5(uniqid('', true));
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function getSalt()
|
||||
{
|
||||
// you *may* need a real salt depending on your encoder
|
||||
@ -50,11 +39,6 @@ class User extends AbstractSource implements UserInterface, \Serializable
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
{
|
||||
return array('ROLE_USER');
|
||||
|
14
application/src/Entity/UserInterface.php
Normal file
14
application/src/Entity/UserInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace App\Entity;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserInterface as SymfonyUserInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface UserInterface extends SymfonyUserInterface, \Serializable
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user