1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-16 04:10:09 -07:00

Add traits

This commit is contained in:
David Hübner 2017-03-24 15:34:59 +01:00
parent 21df3fa58b
commit 060e8ed0d3
15 changed files with 153 additions and 461 deletions

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,21 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Category
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
private $name;
use IdentityTrait;
use NameTrait;
/**
* @var Collection
@ -45,40 +34,6 @@ class Category
$this->parts = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Category
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get parts.
*

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
@ -13,21 +15,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Keyword
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
private $name;
use IdentityTrait;
use NameTrait;
/**
* @var ArrayCollection
@ -44,40 +33,6 @@ class Keyword
$this->parts = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Keyword
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get models.
*

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -13,13 +14,7 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Model
{
* @var string
*
* @ORM\Column(type="string")
* @ORM\Id
* @ORM\Column(type="string", length=255, unique=true)
*/
private $id;
use NumberTrait;
/**
* @var string
@ -49,24 +44,6 @@ class Model
// */
// private $parts;
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* Get id.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
@ -15,12 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Part
{
/**
* @var string
* @ORM\Id
* @ORM\Column(type="string", length=255, unique=true)
*/
private $id;
use NumberTrait;
/**
* @var Type
@ -78,26 +74,6 @@ class Part
$this->relationsFrom = new ArrayCollection();
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*
* @return Part
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return string
*/

View File

@ -28,13 +28,6 @@ class Part_Relation
*/
private $child;
/**
* @var int
*
* @ORM\Column(type="integer")
*/
private $count;
/**
* @var string
*
@ -43,6 +36,13 @@ class Part_Relation
*/
private $type;
/**
* @var int
*
* @ORM\Column(type="integer")
*/
private $count;
/**
* @return Part
*/
@ -53,10 +53,14 @@ class Part_Relation
/**
* @param Part $parent
*
* @return Part_Relation
*/
public function setParent($parent)
{
$this->parent = $parent;
return $this;
}
/**
@ -69,10 +73,14 @@ class Part_Relation
/**
* @param Part $child
*
* @return Part_Relation
*/
public function setChild($child)
{
$this->child = $child;
return $this;
}
/**
@ -85,10 +93,14 @@ class Part_Relation
/**
* @param int $count
*
* @return Part_Relation
*/
public function setCount($count)
{
$this->count = $count;
return $this;
}
/**
@ -101,9 +113,13 @@ class Part_Relation
/**
* @param string $type
*
* @return Part_Relation
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
}

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\IdentityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,14 +15,7 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Type
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
use IdentityTrait;
/**
* @var string
@ -45,14 +39,6 @@ class Type
$this->parts = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,21 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Category
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
protected $name;
use IdentityTrait;
use NameTrait;
/**
* @var Collection
@ -45,40 +34,6 @@ class Category
$this->parts = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Category
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get parts.
*

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,20 +15,16 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Color
{
use NameTrait;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
protected $name;
private $id;
/**
* @var string
@ -58,20 +55,6 @@ class Color
$this->inventoryParts = new ArrayCollection();
}
/**
* Set id.
*
* @var int
*
* @return Color
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get id.
*
@ -82,30 +65,6 @@ class Color
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Color
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set rgb.
*

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\IdentityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,15 +15,7 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Inventory
{
/**
* Inventory ID.
*
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
*/
protected $id;
use IdentityTrait;
/**
* @var int
@ -50,22 +43,6 @@ class Inventory
$this->inventoryParts = new ArrayCollection();
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\NameTrait;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,22 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Part
{
/**
* Part ID number.
*
* @var string
*
* @ORM\Id
* @ORM\Column(name="id", type="string", length=255, unique=true)
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
protected $name;
use NumberTrait;
use NameTrait;
/**
* @var Category
@ -53,54 +41,6 @@ class Part
$this->inventoryParts = new ArrayCollection();
}
/**
* Set number.
*
* @param string $number
*
* @return Part
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get number.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Part
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return Collection
*/

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\NameTrait;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -14,20 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Set
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="id", type="string", length=255, unique=true)
*/
protected $number;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
protected $name;
use NumberTrait;
use NameTrait;
/**
* @var int
@ -53,7 +43,7 @@ class Set
/**
* @var Theme
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Theme", inversedBy="sets")
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Theme", inversedBy="sets", fetch="EAGER")
*/
protected $theme;
@ -65,50 +55,6 @@ class Set
$this->inventories = new ArrayCollection();
}
/**
* @return string
*/
public function getNumber()
{
return $this->number;
}
/**
* @param string $number
*
* @return Set
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
/**
* Set name.
*
* @param string $name
*
* @return Set
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set year.
*

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -13,20 +15,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Theme
{
/**
* @var int
*
* @ORM\Column(type="integer")
* @ORM\Id
*/
protected $id;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
protected $name;
use IdentityTrait;
use NameTrait;
/**
* @var Theme
@ -43,38 +33,6 @@ class Theme
*/
protected $sets;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return Theme
*/

View File

@ -0,0 +1,25 @@
<?php
namespace AppBundle\Entity\Traits;
trait IdentityTrait
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace AppBundle\Entity\Traits;
trait NameTrait
{
/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $name;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*
* @return mixed
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace AppBundle\Entity\Traits;
trait NumberTrait
{
/**
* @var string
*
* @ORM\Id
* @ORM\Column(name="id", type="string", length=255, unique=true)
*/
protected $number;
/**
* @return string
*/
public function getNumber()
{
return $this->number;
}
/**
* @param string $number
*
* @return mixed
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
}