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;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use App\Entity\NodeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -9,8 +11,14 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
*/
|
*/
|
||||||
trait ChildsAttribut {
|
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;
|
protected $childs;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use App\Entity\NodeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -9,17 +10,24 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
trait ParentAttribut {
|
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;
|
protected $parents;
|
||||||
|
|
||||||
public function getParents(): ArrayCollection
|
public function getParents(): ArrayCollection
|
||||||
{
|
{
|
||||||
return $this->parents;
|
return $this->parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setParents(ArrayCollection $parents): void
|
public function setParents(ArrayCollection $parents): void
|
||||||
{
|
{
|
||||||
$this->parents = $parents;
|
$this->parents = $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;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use App\Entity\Attribut\IdAttribut;
|
use App\Entity\Attribut\IdAttribut;
|
||||||
use App\Entity\Attribut\SourceAttribut;
|
use App\Entity\Attribut\SourceAttribut;
|
||||||
use App\Entity\Attribut\ParentAttribut;
|
use App\Entity\Attribut\ParentAttribut;
|
||||||
@ -16,28 +15,9 @@ use App\Entity\Attribut\ChildsAttribut;
|
|||||||
*/
|
*/
|
||||||
class Node implements NodeInterface
|
class Node implements NodeInterface
|
||||||
{
|
{
|
||||||
use IdAttribut,SourceAttribut, ParentAttribut, ChildsAttribut;
|
use IdAttribut,
|
||||||
|
SourceAttribut,
|
||||||
/**
|
ParentAttribut,
|
||||||
* Many Nodes have many parents
|
ChildsAttribut;
|
||||||
* @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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use App\Entity\Attribut\UsernameAttribut;
|
||||||
|
use App\Entity\Attribut\PasswordAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="source_user")
|
* @ORM\Table(name="source_user")
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||||
*/
|
*/
|
||||||
class User extends AbstractSource implements UserInterface, \Serializable
|
class User extends AbstractSource implements UserInterface
|
||||||
{
|
{
|
||||||
/**
|
use UsernameAttribut,PasswordAttribut;
|
||||||
* @ORM\Column(type="string", length=25, unique=true)
|
|
||||||
*/
|
|
||||||
private $username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="string", length=64)
|
|
||||||
*/
|
|
||||||
private $password;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=254, unique=true)
|
* @ORM\Column(type="string", length=254, unique=true)
|
||||||
*/
|
*/
|
||||||
@ -38,11 +32,6 @@ class User extends AbstractSource implements UserInterface, \Serializable
|
|||||||
// $this->salt = md5(uniqid('', true));
|
// $this->salt = md5(uniqid('', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername()
|
|
||||||
{
|
|
||||||
return $this->username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSalt()
|
public function getSalt()
|
||||||
{
|
{
|
||||||
// you *may* need a real salt depending on your encoder
|
// you *may* need a real salt depending on your encoder
|
||||||
@ -50,11 +39,6 @@ class User extends AbstractSource implements UserInterface, \Serializable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword()
|
|
||||||
{
|
|
||||||
return $this->password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoles()
|
public function getRoles()
|
||||||
{
|
{
|
||||||
return array('ROLE_USER');
|
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