Skip to content
Snippets Groups Projects
News.php 4.99 KiB
Newer Older
Stefan Galinski's avatar
Stefan Galinski committed
<?php

namespace SGalinski\SgNews\Domain\Model;

/***************************************************************
 *  Copyright notice
 *
 *  (c) sgalinski Internet Services (http://www.sgalinski.de)
 *
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
 *
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/

use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

/**
 * News
 */
class News extends CategoryAndNews {
	/**
	 * @var string
	 */
	protected $navTitle = '';

	/**
	 * @var string
	 */
	protected $description = '';

	/**
	 * @var string
	 */
	protected $author = '';

	/**
	 * @var boolean
	 */
	protected $highlighted = FALSE;

	/**
	 * @var \DateTime
	 */
	protected $lastUpdated;

	/**
	 * @var \DateTime
	 */
	protected $creationDate;

	/**
	 * @lazy
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGalinski\SgNews\Domain\Model\News>
	 */
	protected $relatedNews;

	/**
	 * @lazy
	 * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
	 */
	protected $authorFrontendUser;

	/**
	 * Constructor
	 */
	public function __construct() {
		parent::__construct();
		$this->relatedNews = new ObjectStorage();
	}

	/**
	 * @param string $author
	 * @return void
	 */
	public function setAuthor($author) {
		$this->author = $author;
	}

	/**
	 * @return string
	 */
	public function getAuthor() {
		return $this->author;
	}

	/**
	 * @param string $description
	 * @return void
	 */
	public function setDescription($description) {
		$this->description = $description;
	}

	/**
	 * @return string
	 */
	public function getDescription() {
		return $this->description;
	}

	/**
	 * @param \DateTime $lastUpdated
	 * @return void
	 */
	public function setLastUpdated(\DateTime $lastUpdated) {
		$this->lastUpdated = $lastUpdated;
	}

	/**
	 * @return \DateTime
	 */
	public function getLastUpdated() {
		return $this->lastUpdated;
	}

	/**
	 * @param \DateTime $creationDate
	 * @return void
	 */
	public function setCreationDate(\DateTime $creationDate) {
		$this->creationDate = $creationDate;
	}

	/**
	 * @return \DateTime
	 */
	public function getCreationDate() {
		return $this->creationDate;
	}

	/**
	 * @param ObjectStorage $relatedNews
	 * @return void
	 */
	public function setRelatedNews(ObjectStorage $relatedNews) {
		$this->relatedNews = $relatedNews;
	}

	/**
	 * @return ObjectStorage
	 */
	public function getRelatedNews() {
		if ($this->relatedNews instanceof LazyLoadingProxy) {
			$this->relatedNews->_loadRealInstance();
		}

		return $this->relatedNews;
	}

	/**
	 * @param News $relatedNews
	 * @return void
	 */
	public function addRelatedNews(News $relatedNews) {
		if ($this->relatedNews instanceof LazyLoadingProxy) {
			$this->relatedNews->_loadRealInstance();
		}

		$this->relatedNews->attach($relatedNews);
	}

	/**
	 * @param News $relatedNews
	 * @return void
	 */
	public function removeRelatedNews(News $relatedNews) {
		if ($this->relatedNews instanceof LazyLoadingProxy) {
			$this->relatedNews->_loadRealInstance();
		}

		$this->relatedNews->detach($relatedNews);
	}

	/**
	 * @param boolean $highlighted
	 */
	public function setHighlighted($highlighted) {
		$this->highlighted = ($highlighted == TRUE);
	}

	/**
	 * @return boolean
	 */
	public function getHighlighted() {
		return $this->highlighted;
	}

	/**
	 * @param int $teaser1HeaderColor
	 * @return void
	 */
	public function setTeaser1HeaderColor($teaser1HeaderColor) {
		$this->teaser1HeaderColor = (int) $teaser1HeaderColor;
	}

	/**
	 * @return int
	 */
	public function getTeaser1HeaderColor() {
		return $this->teaser1HeaderColor;
	}

	/**
	 * @param int $teaser2HeaderColor
	 * @return void
	 */
	public function setTeaser2HeaderColor($teaser2HeaderColor) {
		$this->teaser2HeaderColor = (int) $teaser2HeaderColor;
	}

	/**
	 * @return int
	 */
	public function getTeaser2HeaderColor() {
		return $this->teaser2HeaderColor;
	}

	/**
	 * @param FrontendUser $authorFrontendUser
	 * @return void
	 */
	public function setAuthorFrontendUser(FrontendUser $authorFrontendUser) {
		$this->authorFrontendUser = $authorFrontendUser;
	}

	/**
	 * @return FrontendUser
	 */
	public function getAuthorFrontendUser() {
		if ($this->authorFrontendUser instanceof LazyLoadingProxy) {
			$this->authorFrontendUser->_loadRealInstance();
		}

		return $this->authorFrontendUser;
	}
}

?>