1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-16 12:20: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; namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -14,21 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Category class Category
{ {
/** use IdentityTrait;
* @var int use NameTrait;
*
* @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;
/** /**
* @var Collection * @var Collection
@ -45,40 +34,6 @@ class Category
$this->parts = new ArrayCollection(); $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. * Get parts.
* *

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\LDraw; namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -13,21 +15,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Keyword class Keyword
{ {
/** use IdentityTrait;
* @var int use NameTrait;
*
* @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;
/** /**
* @var ArrayCollection * @var ArrayCollection
@ -44,40 +33,6 @@ class Keyword
$this->parts = new ArrayCollection(); $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. * Get models.
* *

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -14,21 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Category class Category
{ {
/** use IdentityTrait;
* @var int use NameTrait;
*
* @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;
/** /**
* @var Collection * @var Collection
@ -45,40 +34,6 @@ class Category
$this->parts = new ArrayCollection(); $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. * Get parts.
* *

View File

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

View File

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

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\NameTrait;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -14,22 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Part class Part
{ {
/** use NumberTrait;
* Part ID number. use NameTrait;
*
* @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;
/** /**
* @var Category * @var Category
@ -53,54 +41,6 @@ class Part
$this->inventoryParts = new ArrayCollection(); $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 * @return Collection
*/ */

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\NameTrait;
use AppBundle\Entity\Traits\NumberTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -14,20 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Set class Set
{ {
/** use NumberTrait;
* @var string use NameTrait;
*
* @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;
/** /**
* @var int * @var int
@ -53,7 +43,7 @@ class Set
/** /**
* @var Theme * @var Theme
* *
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Theme", inversedBy="sets") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Theme", inversedBy="sets", fetch="EAGER")
*/ */
protected $theme; protected $theme;
@ -65,50 +55,6 @@ class Set
$this->inventories = new ArrayCollection(); $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. * Set year.
* *

View File

@ -2,6 +2,8 @@
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Traits\IdentityTrait;
use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -13,20 +15,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Theme class Theme
{ {
/** use IdentityTrait;
* @var int use NameTrait;
*
* @ORM\Column(type="integer")
* @ORM\Id
*/
protected $id;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
protected $name;
/** /**
* @var Theme * @var Theme
@ -43,38 +33,6 @@ class Theme
*/ */
protected $sets; 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 * @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;
}
}