| 1 | <?php |
||
| 11 | class Article |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @ODM\Id |
||
| 15 | */ |
||
| 16 | private $id; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @ODM\String |
||
| 20 | */ |
||
| 21 | private $title; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @ODM\EmbedOne(targetDocument="Author") |
||
| 25 | */ |
||
| 26 | private $author; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @ODM\EmbedMany(targetDocument="Tag") |
||
| 30 | */ |
||
| 31 | private $tags; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @ODM\String |
||
| 35 | * @var type |
||
| 36 | */ |
||
| 37 | private $content; |
||
| 38 | |||
| 39 | public function __construct() |
||
| 43 | |||
| 44 | public function getId() |
||
| 48 | |||
| 49 | public function getTitle() |
||
| 53 | |||
| 54 | public function setTitle($title) |
||
| 58 | |||
| 59 | public function getContent() |
||
| 63 | |||
| 64 | public function setContent($content) |
||
| 68 | |||
| 69 | public function getAuthor() |
||
| 73 | |||
| 74 | public function setAuthor(Author $author) |
||
| 78 | |||
| 79 | public function getTags() |
||
| 83 | |||
| 84 | public function addTags(Tag $tag) |
||
| 88 | } |
||
| 89 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: