Created
January 29, 2012 13:47
-
-
Save jasongrimes/1698902 to your computer and use it in GitHub Desktop.
Album entity for extending Akrabat's ZF tutorial to use Doctrine
This file contains 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 characters
<?php | |
namespace Album\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* A music album. | |
* | |
* @ORM\Entity | |
* @ORM\Table(name="album") | |
* @property string $artist | |
* @property string $title | |
* @property int $id | |
*/ | |
class Album { | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer"); | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $artist; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $title; | |
/** | |
* Magic getter to expose protected properties. | |
* | |
* @param string $property | |
* @return mixed | |
*/ | |
public function __get($property) { | |
return $this->$property; | |
} | |
/** | |
* Magic setter to save protected properties. | |
* | |
* @param string $property | |
* @param mixed $value | |
*/ | |
public function __set($property, $value) { | |
$this->$property = $value; | |
} | |
/** | |
* Convert the object to an array. | |
* | |
* @return array | |
*/ | |
public function toArray() { | |
return get_object_vars($this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment