diff --git a/src/AppBundle/Entity/LDraw/Category.php b/src/AppBundle/Entity/LDraw/Category.php index 4d9bd1e..607547c 100644 --- a/src/AppBundle/Entity/LDraw/Category.php +++ b/src/AppBundle/Entity/LDraw/Category.php @@ -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. * diff --git a/src/AppBundle/Entity/LDraw/Keyword.php b/src/AppBundle/Entity/LDraw/Keyword.php index d13cace..7db27ba 100644 --- a/src/AppBundle/Entity/LDraw/Keyword.php +++ b/src/AppBundle/Entity/LDraw/Keyword.php @@ -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. * diff --git a/src/AppBundle/Entity/LDraw/Model.php b/src/AppBundle/Entity/LDraw/Model.php index fa64a30..e52482c 100644 --- a/src/AppBundle/Entity/LDraw/Model.php +++ b/src/AppBundle/Entity/LDraw/Model.php @@ -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 */ diff --git a/src/AppBundle/Entity/LDraw/Part.php b/src/AppBundle/Entity/LDraw/Part.php index caaed19..39abf69 100644 --- a/src/AppBundle/Entity/LDraw/Part.php +++ b/src/AppBundle/Entity/LDraw/Part.php @@ -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 */ diff --git a/src/AppBundle/Entity/LDraw/Part_Relation.php b/src/AppBundle/Entity/LDraw/Part_Relation.php index 5f330ab..3943ff5 100644 --- a/src/AppBundle/Entity/LDraw/Part_Relation.php +++ b/src/AppBundle/Entity/LDraw/Part_Relation.php @@ -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; } } diff --git a/src/AppBundle/Entity/LDraw/Type.php b/src/AppBundle/Entity/LDraw/Type.php index 9ea5f4f..fe49c7a 100644 --- a/src/AppBundle/Entity/LDraw/Type.php +++ b/src/AppBundle/Entity/LDraw/Type.php @@ -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 */ diff --git a/src/AppBundle/Entity/Rebrickable/Category.php b/src/AppBundle/Entity/Rebrickable/Category.php index dca48f7..92635f0 100644 --- a/src/AppBundle/Entity/Rebrickable/Category.php +++ b/src/AppBundle/Entity/Rebrickable/Category.php @@ -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. * diff --git a/src/AppBundle/Entity/Rebrickable/Color.php b/src/AppBundle/Entity/Rebrickable/Color.php index e6d65d1..5db32d0 100644 --- a/src/AppBundle/Entity/Rebrickable/Color.php +++ b/src/AppBundle/Entity/Rebrickable/Color.php @@ -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. * diff --git a/src/AppBundle/Entity/Rebrickable/Inventory.php b/src/AppBundle/Entity/Rebrickable/Inventory.php index b818668..36777df 100644 --- a/src/AppBundle/Entity/Rebrickable/Inventory.php +++ b/src/AppBundle/Entity/Rebrickable/Inventory.php @@ -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 */ diff --git a/src/AppBundle/Entity/Rebrickable/Part.php b/src/AppBundle/Entity/Rebrickable/Part.php index c172f9d..33ee4c6 100644 --- a/src/AppBundle/Entity/Rebrickable/Part.php +++ b/src/AppBundle/Entity/Rebrickable/Part.php @@ -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 */ diff --git a/src/AppBundle/Entity/Rebrickable/Set.php b/src/AppBundle/Entity/Rebrickable/Set.php index 1fdf69f..f529534 100644 --- a/src/AppBundle/Entity/Rebrickable/Set.php +++ b/src/AppBundle/Entity/Rebrickable/Set.php @@ -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. * diff --git a/src/AppBundle/Entity/Rebrickable/Theme.php b/src/AppBundle/Entity/Rebrickable/Theme.php index 4c4fc98..65ad53c 100644 --- a/src/AppBundle/Entity/Rebrickable/Theme.php +++ b/src/AppBundle/Entity/Rebrickable/Theme.php @@ -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 */ diff --git a/src/AppBundle/Entity/Traits/IdentityTrait.php b/src/AppBundle/Entity/Traits/IdentityTrait.php new file mode 100644 index 0000000..bbe252a --- /dev/null +++ b/src/AppBundle/Entity/Traits/IdentityTrait.php @@ -0,0 +1,25 @@ +id; + } +} diff --git a/src/AppBundle/Entity/Traits/NameTrait.php b/src/AppBundle/Entity/Traits/NameTrait.php new file mode 100644 index 0000000..719a2f9 --- /dev/null +++ b/src/AppBundle/Entity/Traits/NameTrait.php @@ -0,0 +1,33 @@ +name; + } + + /** + * @param string $name + * + * @return mixed + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } +} diff --git a/src/AppBundle/Entity/Traits/NumberTrait.php b/src/AppBundle/Entity/Traits/NumberTrait.php new file mode 100644 index 0000000..340aa63 --- /dev/null +++ b/src/AppBundle/Entity/Traits/NumberTrait.php @@ -0,0 +1,34 @@ +number; + } + + /** + * @param string $number + * + * @return mixed + */ + public function setNumber($number) + { + $this->number = $number; + + return $this; + } +}