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