| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace internship\bo;
- use ArrayObject;
- use n2n\persistence\orm\annotation\AnnoOneToMany;
- use n2n\reflection\annotation\AnnoInit;
- use n2n\reflection\ObjectAdapter;
- class Category extends ObjectAdapter implements \JsonSerializable {
- private static function _annos(AnnoInit $ai) {
- $ai->p('articles', new AnnoOneToMany(Article::getClass(), 'category'));
- }
- private int $id;
- private ArrayObject $articles;
- private string $name;
- private string $text;
- /**
- * @return int
- */
- public function getId(): int {
- return $this->id;
- }
- /**
- * @param int $id
- */
- public function setId(int $id): void {
- $this->id = $id;
- }
- /**
- * @return string
- */
- public function getName(): string {
- return $this->name;
- }
- /**
- * @param string $name
- */
- public function setName(string $name): void {
- $this->name = $name;
- }
- /**
- * @return string
- */
- public function getText(): string {
- return $this->text;
- }
- /**
- * @param string $text
- */
- public function setText(string $text): void {
- $this->text = $text;
- }
- /**
- * @return ArrayObject
- */
- public function getArticles(): ArrayObject
- {
- return $this->articles;
- }
- /**
- * @param ArrayObject $articles
- */
- public function setArticles(ArrayObject $articles): void
- {
- $this->articles = $articles;
- }
- function jsonSerialize(): mixed {
- return [
- 'id' => $this->id,
- 'title' => $this->name,
- 'text' => $this->text
- ];
- }
- }
|