<?php
/**
* Inheritance: no
* Variants: no
*
* Fields Summary:
* - date [date]
* - headline [textarea]
* - intro [textarea]
* - download [link]
* - content [fieldcollections]
* - teaserImage [manyToOneRelation]
*/
namespace Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
use Pimcore\Model\DataObject\PreGetValueHookInterface;
/**
* @method static \Pimcore\Model\DataObject\News\Listing getList(array $config = [])
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByDate($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByHeadline($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByIntro($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByTeaserImage($value, $limit = 0, $offset = 0, $objectTypes = null)
*/
class News extends Concrete
{
protected $o_classId = "News";
protected $o_className = "News";
protected $date;
protected $headline;
protected $intro;
protected $download;
protected $content;
protected $teaserImage;
/**
* @param array $values
* @return \Pimcore\Model\DataObject\News
*/
public static function create($values = array()) {
$object = new static();
$object->setValues($values);
return $object;
}
/**
* Get date - Date
* @return \Carbon\Carbon|null
*/
public function getDate(): ?\Carbon\Carbon
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("date");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->date;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set date - Date
* @param \Carbon\Carbon|null $date
* @return \Pimcore\Model\DataObject\News
*/
public function setDate(?\Carbon\Carbon $date)
{
$this->date = $date;
return $this;
}
/**
* Get headline - Headline
* @return string|null
*/
public function getHeadline(): ?string
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("headline");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->headline;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set headline - Headline
* @param string|null $headline
* @return \Pimcore\Model\DataObject\News
*/
public function setHeadline(?string $headline)
{
$this->headline = $headline;
return $this;
}
/**
* Get intro - Intro
* @return string|null
*/
public function getIntro(): ?string
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("intro");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->intro;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set intro - Intro
* @param string|null $intro
* @return \Pimcore\Model\DataObject\News
*/
public function setIntro(?string $intro)
{
$this->intro = $intro;
return $this;
}
/**
* Get download - Download
* @return \Pimcore\Model\DataObject\Data\Link|null
*/
public function getDownload(): ?\Pimcore\Model\DataObject\Data\Link
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("download");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->download;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set download - Download
* @param \Pimcore\Model\DataObject\Data\Link|null $download
* @return \Pimcore\Model\DataObject\News
*/
public function setDownload(?\Pimcore\Model\DataObject\Data\Link $download)
{
$this->download = $download;
return $this;
}
/**
* @return \Pimcore\Model\DataObject\Fieldcollection|null
*/
public function getContent(): ?\Pimcore\Model\DataObject\Fieldcollection
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("content");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("content")->preGetData($this);
return $data;
}
/**
* Set content - Content
* @param \Pimcore\Model\DataObject\Fieldcollection|null $content
* @return \Pimcore\Model\DataObject\News
*/
public function setContent(?\Pimcore\Model\DataObject\Fieldcollection $content)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\Fieldcollections $fd */
$fd = $this->getClass()->getFieldDefinition("content");
$this->content = $fd->preSetData($this, $content);
return $this;
}
/**
* Get teaserImage - Teaser Image
* @return \Pimcore\Model\Asset\Image|null
*/
public function getTeaserImage(): ?\Pimcore\Model\Element\AbstractElement
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("teaserImage");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("teaserImage")->preGetData($this);
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set teaserImage - Teaser Image
* @param \Pimcore\Model\Asset\Image|null $teaserImage
* @return \Pimcore\Model\DataObject\News
*/
public function setTeaserImage(?\Pimcore\Model\Element\AbstractElement $teaserImage)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToOneRelation $fd */
$fd = $this->getClass()->getFieldDefinition("teaserImage");
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getTeaserImage();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
$isEqual = $fd->isEqual($currentData, $teaserImage);
if (!$isEqual) {
$this->markFieldDirty("teaserImage", true);
}
$this->teaserImage = $fd->preSetData($this, $teaserImage);
return $this;
}
}