<?php
/**
* Inheritance: yes
* Variants: yes
Fields Summary:
- localizedfields [localizedfields]
-- title [input]
-- shortText [textarea]
- content [fieldcollections]
- date [datetime]
- gallery [imageGallery]
- completenessPercentage [numeric]
- specificAttributes [objectbricks]
- listData [table]
- specificStore [classificationstore]
*/
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 getByLocalizedfields($field, $value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByTitle($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByShortText($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @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 getByCompletenessPercentage($value, $limit = 0, $offset = 0, $objectTypes = null)
*/
class News extends Concrete
{
protected $o_classId = "NE";
protected $o_className = "News";
protected $localizedfields;
protected $content;
protected $date;
protected $gallery;
protected $completenessPercentage;
protected $specificAttributes;
protected $listData;
protected $specificStore;
/**
* @param array $values
* @return \Pimcore\Model\DataObject\News
*/
public static function create($values = array()) {
$object = new static();
$object->setValues($values);
return $object;
}
/**
* Get localizedfields -
* @return \Pimcore\Model\DataObject\Localizedfield|null
*/
public function getLocalizedfields(): ?\Pimcore\Model\DataObject\Localizedfield
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("localizedfields");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("localizedfields")->preGetData($this);
if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("localizedfields")->isEmpty($data)) {
try {
return $this->getValueFromParent("localizedfields");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Get title - Title
* @return string|null
*/
public function getTitle($language = null): ?string
{
$data = $this->getLocalizedfields()->getLocalizedValue("title", $language);
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("title");
if ($preValue !== null) {
return $preValue;
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Get shortText - Short Text
* @return string|null
*/
public function getShortText($language = null): ?string
{
$data = $this->getLocalizedfields()->getLocalizedValue("shortText", $language);
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("shortText");
if ($preValue !== null) {
return $preValue;
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set localizedfields -
* @param \Pimcore\Model\DataObject\Localizedfield|null $localizedfields
* @return \Pimcore\Model\DataObject\News
*/
public function setLocalizedfields(?\Pimcore\Model\DataObject\Localizedfield $localizedfields)
{
$inheritValues = self::getGetInheritedValues();
self::setGetInheritedValues(false);
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getLocalizedfields();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
self::setGetInheritedValues($inheritValues);
$this->markFieldDirty("localizedfields", true);
$this->localizedfields = $localizedfields;
return $this;
}
/**
* Set title - Title
* @param string|null $title
* @return \Pimcore\Model\DataObject\News
*/
public function setTitle (?string $title, $language = null)
{
$isEqual = false;
$this->getLocalizedfields()->setLocalizedValue("title", $title, $language, !$isEqual);
return $this;
}
/**
* Set shortText - Short Text
* @param string|null $shortText
* @return \Pimcore\Model\DataObject\News
*/
public function setShortText (?string $shortText, $language = null)
{
$isEqual = false;
$this->getLocalizedfields()->setLocalizedValue("shortText", $shortText, $language, !$isEqual);
return $this;
}
/**
* @return \Pimcore\Model\DataObject\Fieldcollection|null
*/
public function getContent()
{
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 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 (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("date")->isEmpty($data)) {
try {
return $this->getValueFromParent("date");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
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 gallery - Gallery
* @return \Pimcore\Model\DataObject\Data\ImageGallery|null
*/
public function getGallery(): ?\Pimcore\Model\DataObject\Data\ImageGallery
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("gallery");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->gallery;
if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("gallery")->isEmpty($data)) {
try {
return $this->getValueFromParent("gallery");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set gallery - Gallery
* @param \Pimcore\Model\DataObject\Data\ImageGallery|null $gallery
* @return \Pimcore\Model\DataObject\News
*/
public function setGallery(?\Pimcore\Model\DataObject\Data\ImageGallery $gallery)
{
$this->gallery = $gallery;
return $this;
}
/**
* Get completenessPercentage - Completeness %
* @return float|null
*/
public function getCompletenessPercentage(): ?float
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("completenessPercentage");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->completenessPercentage;
if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("completenessPercentage")->isEmpty($data)) {
try {
return $this->getValueFromParent("completenessPercentage");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set completenessPercentage - Completeness %
* @param float|null $completenessPercentage
* @return \Pimcore\Model\DataObject\News
*/
public function setCompletenessPercentage(?float $completenessPercentage)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\Numeric $fd */
$fd = $this->getClass()->getFieldDefinition("completenessPercentage");
$this->completenessPercentage = $fd->preSetData($this, $completenessPercentage);
return $this;
}
/**
* @return \Pimcore\Model\DataObject\News\SpecificAttributes
*/
public function getSpecificAttributes(): ?\Pimcore\Model\DataObject\Objectbrick
{
$data = $this->specificAttributes;
if (!$data) {
if (\Pimcore\Tool::classExists("\\Pimcore\\Model\\DataObject\\News\\SpecificAttributes")) {
$data = new \Pimcore\Model\DataObject\News\SpecificAttributes($this, "specificAttributes");
$this->specificAttributes = $data;
} else {
return null;
}
}
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("specificAttributes");
if ($preValue !== null) {
return $preValue;
}
}
return $data;
}
/**
* Set specificAttributes - Specific Attributes
* @param \Pimcore\Model\DataObject\Objectbrick|null $specificAttributes
* @return \Pimcore\Model\DataObject\News
*/
public function setSpecificAttributes(?\Pimcore\Model\DataObject\Objectbrick $specificAttributes)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\Objectbricks $fd */
$fd = $this->getClass()->getFieldDefinition("specificAttributes");
$this->specificAttributes = $fd->preSetData($this, $specificAttributes);
return $this;
}
/**
* Get listData - List
* @return array
*/
public function getListData(): array
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("listData");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->listData;
if(\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("listData")->isEmpty($data)) {
try {
return $this->getValueFromParent("listData");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain() ?? [];
}
return $data ?? [];
}
/**
* Set listData - List
* @param ?array $listData
* @return \Pimcore\Model\DataObject\News
*/
public function setListData(?array $listData)
{
$this->listData = $listData;
return $this;
}
/**
* Get specificStore - Store Data
* @return \Pimcore\Model\DataObject\Classificationstore|null
*/
public function getSpecificStore(): ?\Pimcore\Model\DataObject\Classificationstore
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("specificStore");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("specificStore")->preGetData($this);
if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("specificStore")->isEmpty($data)) {
try {
return $this->getValueFromParent("specificStore");
} catch (InheritanceParentNotFoundException $e) {
// no data from parent available, continue ...
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set specificStore - Store Data
* @param \Pimcore\Model\DataObject\Classificationstore|null $specificStore
* @return \Pimcore\Model\DataObject\News
*/
public function setSpecificStore(?\Pimcore\Model\DataObject\Classificationstore $specificStore)
{
$this->specificStore = $specificStore;
return $this;
}
}