Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ArticleModule;
- /**
- * @property-read int $id
- * @property string $title
- * @property string $perex
- * @property string $content
- * @property string $visibility
- * @property string $type
- * @property string $status
- * @property int $order
- * @property DateTime $created
- * @property DateTime|NULL $modified
- * @property int|NULL $parent_id
- * @property int $user_id
- */
- class Article extends \YetORM\Entity {
- /** @param int $id */
- public function setId($id) {}
- /** @return \YetORM\EntityCollection */
- public function getSections() {
- return $this->getMany('Section', 'article_has_section', 'section');
- }
- /** @return \YetORM\EntityCollection */
- public function getTags() {
- return $this->getMany('Tag', 'article_has_tag', 'tag');
- }
- /** @return \UserModule\User */
- public function getAuthor() {
- return new \UserModule\User($this->row->user);
- }
- /**
- * @param \UserModule\User
- * @return \ArticleModule\Article
- */
- function setAuthor(\UserModule\User $user) {
- $this->row->user_id = $user->id;
- return $this;
- }
- /** @return array */
- function toArray() {
- $return = parent::toArray();
- $author = $this->getAuthor();
- $return['author'] = $author->name . ' ' . $author->surname;
- $return['tags'] = array();
- foreach ($this->getTags() as $tag) {
- $return['tags'][] = $tag->getName();
- }
- $return['sections'] = array();
- foreach ($this->getSections() as $section) {
- $return['sections'][] = $section->getName();
- }
- return $return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement