From 12e7dafe0d5f86ae11cbc9d0a38e9ff75eb5c15b Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 19 Jul 2014 09:25:09 +0200 Subject: [PATCH] Introduced a BaseEntity for more easy access to all the properties. --- .../CalciferBundle/Entity/BaseEntity.php | 58 +++++ .../Bundle/CalciferBundle/Entity/Event.php | 201 +----------------- .../Bundle/CalciferBundle/Entity/Location.php | 118 +--------- .../CalciferBundle/Entity/RepeatEvent.php | 23 ++ .../Bundle/CalciferBundle/Entity/Tag.php | 69 +----- 5 files changed, 97 insertions(+), 372 deletions(-) create mode 100755 src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php create mode 100755 src/Hackspace/Bundle/CalciferBundle/Entity/RepeatEvent.php diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php b/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php new file mode 100755 index 0000000..db1bf2b --- /dev/null +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php @@ -0,0 +1,58 @@ +$name; + } else { + throw new \Exception("Property {$name} does not Exists"); + } + } + + public function __set($name,$value) { + if (property_exists($this,$name)) { + $this->$name = $value; + return $this; + } else { + throw new \Exception("Property {$name} does not Exists"); + } + } +} \ No newline at end of file diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php b/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php index 82dfc4e..88049ed 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php @@ -11,51 +11,42 @@ use Doctrine\ORM\PersistentCollection; * @ORM\Table(name="events") * @ORM\Entity */ -class Event +class Event extends BaseEntity { - /** - * @var integer - * - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - */ - private $id; - /** * @var \DateTime * * @ORM\Column(name="startdate", type="datetimetz") */ - private $startdate; + protected $startdate; /** * @var \DateTime * * @ORM\Column(name="enddate", type="datetimetz", nullable=true) */ - private $enddate; + protected $enddate; /** * @var string * * @ORM\Column(name="summary", type="string", length=255) */ - private $summary; + protected $summary; /** * @var string * * @ORM\Column(name="description", type="text", nullable=true) */ - private $description; + protected $description; /** * @var string * * @ORM\Column(name="locations_id", type="integer", nullable=true) */ - private $locations_id; + protected $locations_id; /** * @var Location @@ -63,14 +54,14 @@ class Event * @ORM\ManyToOne(targetEntity="Location") * @ORM\JoinColumn(name="locations_id", referencedColumnName="id") */ - private $location; + protected $location; /** * @var string * * @ORM\Column(name="url", type="string", length=255, nullable=true) */ - private $url; + protected $url; /** * @var array @@ -81,179 +72,7 @@ class Event * inverseJoinColumns={@ORM\JoinColumn(name="tags_id", referencedColumnName="id")} * ) */ - private $tags = []; - - /** - * @var string - * - * @ORM\Column(name="slug", type="string", length=255,options={"default" = ""}) - */ - private $slug = ''; - - /** - * @param string $slug - */ - public function setSlug($slug) - { - $this->slug = $slug; - } - - /** - * @return string - */ - public function getSlug() - { - return $this->slug; - } - - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Set startdate - * - * @param \DateTime $startdate - * @return Event - */ - public function setStartdate($startdate) - { - $this->startdate = $startdate; - - return $this; - } - - /** - * Get startdate - * - * @return \DateTime - */ - public function getStartdate() - { - return $this->startdate; - } - - /** - * Set enddate - * - * @param \DateTime $enddate - * @return Event - */ - public function setEnddate($enddate) - { - $this->enddate = $enddate; - - return $this; - } - - /** - * Get enddate - * - * @return \DateTime - */ - public function getEnddate() - { - return $this->enddate; - } - - /** - * Set summary - * - * @param string $summary - * @return Event - */ - public function setSummary($summary) - { - $this->summary = $summary; - - return $this; - } - - /** - * Get summary - * - * @return string - */ - public function getSummary() - { - return $this->summary; - } - - /** - * Set description - * - * @param string $description - * @return Event - */ - public function setDescription($description) - { - $this->description = $description; - - return $this; - } - - /** - * Get description - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Set location - * - * @param string $locations_id - * @return Event - */ - public function setLocationsID($locations_id) - { - $this->locations_id = $locations_id; - - return $this; - } - - /** - * Get location - * - * @return string - */ - public function getLocationsID() - { - return $this->locations_id; - } - - /** - * Set url - * - * @param string $url - * @return Event - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * Get url - * - * @return string - */ - public function getUrl() - { - return $this->url; - } + protected $tags = []; /** * @param \Hackspace\Bundle\CalciferBundle\Entity\Location $location @@ -303,7 +122,7 @@ class Event if (count($this->tags) > 0) { $tags = []; foreach ($this->tags as $tag) { - $tags[] = $tag->getName(); + $tags[] = $tag->name; } return implode(',',$tags); } else { diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php b/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php index 8d3b6a2..af10407 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php @@ -10,138 +10,28 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="locations") * @ORM\Entity */ -class Location +class Location extends BaseEntity { - /** - * @var integer - * - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - */ - private $id; - /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ - private $name; + protected $name; /** * @var float * * @ORM\Column(name="lon", type="float", nullable=true) */ - private $lon; + protected $lon; /** * @var float * * @ORM\Column(name="lat", type="float", nullable=true) */ - private $lat; - - /** - * @var string - * - * @ORM\Column(name="slug", type="string", length=255,options={"default" = ""}) - */ - private $slug = ''; - - /** - * @param string $slug - */ - public function setSlug($slug) - { - $this->slug = $slug; - } - - /** - * @return string - */ - public function getSlug() - { - return $this->slug; - } + protected $lat; - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Set name - * - * @param string $name - * @return Location - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Set lon - * - * @param float $lon - * @return Location - */ - public function setLon($lon) - { - $this->lon = $lon; - - return $this; - } - - /** - * Get lon - * - * @return float - */ - public function getLon() - { - return $this->lon; - } - - /** - * Set lat - * - * @param float $lat - * @return Location - */ - public function setLat($lat) - { - $this->lat = $lat; - - return $this; - } - - /** - * Get lat - * - * @return float - */ - public function getLat() - { - return $this->lat; - } } diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatEvent.php b/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatEvent.php new file mode 100755 index 0000000..aa4818d --- /dev/null +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatEvent.php @@ -0,0 +1,23 @@ +slug = $slug; - } - - /** - * @return string - */ - public function getSlug() - { - return $this->slug; - } - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Set name - * - * @param string $name - * @return Tag - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } + protected $name; }