Introduced a BaseEntity for more easy access to all the properties.

This commit is contained in:
Tim Schumacher 2014-07-19 09:25:09 +02:00
parent e3ca015608
commit 12e7dafe0d
5 changed files with 97 additions and 372 deletions

View file

@ -0,0 +1,58 @@
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 13.07.14
* Time: 13:55
*/
namespace Hackspace\Bundle\CalciferBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
/**
* @ORM\MappedSuperclass
*/
abstract class BaseEntity {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255,options={"default" = ""})
*/
protected $slug = '';
public function __isset($name) {
if (property_exists($this,$name)) {
return true;
} else {
return false;
}
}
public function __get($name) {
if (property_exists($this,$name)) {
return $this->$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");
}
}
}