Last active
August 29, 2015 13:59
-
-
Save devmatheus/10668172 to your computer and use it in GitHub Desktop.
Revisions
-
devmatheus revised this gist
Apr 14, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,6 +42,10 @@ public function __construct($options = null) { $hydrator = new Hydrator\ClassMethods; $hydrator->hydrate($options, $this); } public function __toString() { return $this->titulo; } public function __call ($methodName, $params = null) { $methodPrefix = substr($methodName, 0, 3); -
devmatheus created this gist
Apr 14, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ <?php namespace Sessao\Entity; use Doctrine\ORM\Mapping as ORM; use Zend\Stdlib\Hydrator; /** * @ORM\Entity * @ORM\Table(name="sessao") * @ORM\Entity(repositoryClass="Doctrine\ORM\EntityRepository") */ class Sessao { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue * @var int */ protected $id; /** * @ORM\Column(type="text", length=150) * @var string */ protected $titulo; /** * @ORM\Column(type="text") * @var int */ protected $slug; /** * @ORM\Column(type="text") * @var string */ protected $texto; public function __construct($options = null) { $hydrator = new Hydrator\ClassMethods; $hydrator->hydrate($options, $this); } public function __call ($methodName, $params = null) { $methodPrefix = substr($methodName, 0, 3); $property = strtolower(substr($methodName, 3)); if ($methodPrefix == 'set' && count($params) == 1) { $this->$property = $params[0]; return $this; } elseif ($methodPrefix == 'get' && property_exists($this, $property)) { return $this->$property; } throw new \Exception($methodName . ' não definido em ' . get_class($this)); } public function toArray () { $reflect = new \ReflectionClass($this); $props = $reflect->getProperties(); $data = array(); foreach ($props as $property) { $property = $property->getName(); $data[$property] = $this->$property; } return $data; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,91 @@ <?php namespace Sessao\Entity; use Doctrine\ORM\Mapping as ORM; use Zend\Stdlib\Hydrator; /** * @ORM\Entity * @ORM\Table(name="sessao") * @ORM\Entity(repositoryClass="Doctrine\ORM\EntityRepository") */ class Sessao { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue * @var int */ protected $id; /** * @ORM\Column(type="text", length=150) * @var string */ protected $titulo; /** * @ORM\Column(type="text") * @var int */ protected $slug; /** * @ORM\Column(type="text") * @var string */ protected $texto; public function __construct($options = null) { $hydrator = new Hydrator\ClassMethods; $hydrator->hydrate($options, $this); } public function getId() { return $this->id; } public function setId($id) { $this->id = $id; return $this; } public function getTitulo() { return $this->titulo; } public function setTitulo($titulo) { $this->titulo = $titulo; return $this; } public function getSlug() { return $this->slug; } public function setSlug($slug) { $this->slug = $slug; return $this; } public function getTexto() { return $this->texto; } public function setTexto($texto) { $this->texto = $texto; return $this; } public function __toString() { return $this->titulo; } public function toArray() { $hydrator = new Hydrator\ClassMethods; return $hydrator->extract($this); } }