<?php
namespace Mm\Beton\Planungsatlas\AtlasBundle\Entity\Main;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
/**
* Class ConstructionType
*
* @package Mm\Beton\Planungsatlas\AtlasBundle\Entity
* @ORM\Entity
* @ORM\Table(name="construction_types")
*/
class ConstructionType extends AbstractModel implements HasParentModelInterface
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @var ArrayCollection
* @ORM\OneToMany(targetEntity="ConstructionElement", mappedBy="constructionType")
*/
private $constructionElements;
/**
* @ORM\ManyToOne(targetEntity="Construction", inversedBy="constructionTypes")
* @ORM\JoinColumn(name="construction_id", referencedColumnName="id", nullable=false)
*/
private $construction;
/**
* Constructor
*/
public function __construct()
{
$this->constructionElements = new ArrayCollection();
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return ConstructionElement[]
*/
public function getConstructionElements()
{
return $this->constructionElements;
}
/**
* @param ConstructionElement[] $constructionElements
*/
public function setConstructionElements(ArrayCollection $constructionElements)
{
$this->constructionElements = $constructionElements;
}
/**
* @return Construction
*/
public function getConstruction()
{
return $this->construction;
}
/**
* @param Construction $construction
*/
public function setConstruction($construction)
{
$this->construction = $construction;
}
/**
* {@inheritdoc}
*/
public function setParentModel($parentModel)
{
if (!($parentModel instanceof Construction)) {
throw new Exception('invalid parent');
}
$this->setConstruction($parentModel);
}
}