| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- namespace internship\bo;
- use n2n\reflection\ObjectAdapter;
- use internship\bo\NewsCategory;
- use n2n\reflection\annotation\AnnoInit;
- use n2n\persistence\orm\annotation\AnnoManyToOne;
- use n2n\persistence\orm\annotation\AnnoManyToMany;
- use n2n\persistence\orm\annotation\AnnoManagedFile;
- use n2n\persistence\orm\CascadeType;
- class NewsItem extends ObjectAdapter {
- private static function _annos(AnnoInit $ai) {
- $ai->p('category', new AnnoManyToOne(NewsCategory::getClass(), CascadeType::MERGE|CascadeType::PERSIST));
- $ai->p('tags', new AnnoManyToMany(NewsTag::getClass()));
- //$ai->p('imageFile', new AnnoManagedFile());
- }
- private int $id;
- private string $title;
- private string $lead;
- private string $content;
- private ?string $imageFile;
- private string $urlPart;
- private NewsCategory $category;
- private \ArrayObject $tags;
- function __construct() {
- $this->tags = new \ArrayObject();
- }
- /**
- * @return int
- */
- public function getId(): int {
- return $this->id;
- }
- /**
- * @return NewsCategory
- */
- public function getCategory(): NewsCategory {
- return $this->category;
- }
- /**
- * @param NewsCategory $category
- */
- public function setCategory($category): void {
- $this->category = $category;
- }
- /**
- * @return \ArrayObject
- */
- public function getTags(): \ArrayObject {
- return $this->tags;
- }
- /**
- * @param \ArrayObject $tags
- */
- public function setTags(\ArrayObject $tags): void {
- $this->tags = $tags;
- }
- /**
- * @return string
- */
- public function getTitle(): string {
- return $this->title;
- }
- /**
- * @param string $title
- */
- public function setTitle(string $title): void {
- $this->title = $title;
- }
- /**
- * @return string
- */
- public function getLead(): string {
- return $this->lead;
- }
- /**
- * @param string $lead
- */
- public function setLead(string $lead): void {
- $this->lead = $lead;
- }
- /**
- * @return string
- */
- public function getContent(): string {
- return $this->content;
- }
- /**
- * @param string $content
- */
- public function setContent(string $content): void {
- $this->content = $content;
- }
- /**
- * @return string
- */
- public function getImageFile(): string {
- return $this->imageFile;
- }
- /**
- * @param string $imageFile
- */
- public function setImageFile(?string $imageFile): void {
- $this->imageFile = $imageFile;
- }
- /**
- * @return string
- */
- public function getUrlPart() {
- return $this->urlPart;
- }
- /**
- * @param string $urlPart
- */
- public function setUrlPart($urlPart) {
- $this->urlPart = $urlPart;
- }
- public function equals(NewsItem $newsItem) {
- return $this->id == $newsItem->getId();
- }
- }
|