<?php
/**
* Inheritance: no
* Variants: no
*
* Fields Summary:
* - teaserCategories [manyToManyObjectRelation]
* - teaserImage [image]
* - localizedfields [localizedfields]
* -- title [input]
* -- description [textarea]
* -- page [manyToOneRelation]
* -- linkText [input]
*/
namespace Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
use Pimcore\Model\DataObject\PreGetValueHookInterface;
/**
* @method static \Pimcore\Model\DataObject\Teaser\Listing getList(array $config = [])
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTeaserCategories($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTeaserImage($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLocalizedfields($field, $value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTitle($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByDescription($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByPage($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLinkText($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
*/
class Teaser extends Concrete
{
protected $o_classId = "teaser";
protected $o_className = "Teaser";
protected $teaserCategories;
protected $teaserImage;
protected $localizedfields;
/**
* @param array $values
* @return \Pimcore\Model\DataObject\Teaser
*/
public static function create($values = array()) {
$object = new static();
$object->setValues($values);
return $object;
}
/**
* Get teaserCategories - Teaser Categories
* @return \Pimcore\Model\DataObject\TeaserCategory[]
*/
public function getTeaserCategories()
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("teaserCategories");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("teaserCategories")->preGetData($this);
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set teaserCategories - Teaser Categories
* @param \Pimcore\Model\DataObject\TeaserCategory[] $teaserCategories
* @return \Pimcore\Model\DataObject\Teaser
*/
public function setTeaserCategories($teaserCategories)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToManyObjectRelation $fd */
$fd = $this->getClass()->getFieldDefinition("teaserCategories");
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getTeaserCategories();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
$isEqual = $fd->isEqual($currentData, $teaserCategories);
if (!$isEqual) {
$this->markFieldDirty("teaserCategories", true);
}
$this->teaserCategories = $fd->preSetData($this, $teaserCategories);
return $this;
}
/**
* Get teaserImage - Teaser Image
* @return \Pimcore\Model\Asset\Image|null
*/
public function getTeaserImage()
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("teaserImage");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->teaserImage;
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\Teaser
*/
public function setTeaserImage($teaserImage)
{
$this->teaserImage = $teaserImage;
return $this;
}
/**
* Get localizedfields -
* @return \Pimcore\Model\DataObject\Localizedfield|null
*/
public function getLocalizedfields()
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("localizedfields");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("localizedfields")->preGetData($this);
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Get title - Title (optional)
* @return string|null
*/
public function getTitle($language = null)
{
$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 description - Description (optional)
* @return string|null
*/
public function getDescription($language = null)
{
$data = $this->getLocalizedfields()->getLocalizedValue("description", $language);
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("description");
if ($preValue !== null) {
return $preValue;
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Get page - Page
* @return \Pimcore\Model\Document\Page | \Pimcore\Model\Document\Link|null
*/
public function getPage($language = null)
{
$data = $this->getLocalizedfields()->getLocalizedValue("page", $language);
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("page");
if ($preValue !== null) {
return $preValue;
}
}
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Get linkText - Link Text
* @return string|null
*/
public function getLinkText($language = null)
{
$data = $this->getLocalizedfields()->getLocalizedValue("linkText", $language);
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("linkText");
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\Teaser
*/
public function setLocalizedfields($localizedfields)
{
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getLocalizedfields();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
$this->markFieldDirty("localizedfields", true);
$this->localizedfields = $localizedfields;
return $this;
}
/**
* Set title - Title (optional)
* @param string|null $title
* @return \Pimcore\Model\DataObject\Teaser
*/
public function setTitle ($title, $language = null)
{
$isEqual = false;
$this->getLocalizedfields()->setLocalizedValue("title", $title, $language, !$isEqual);
return $this;
}
/**
* Set description - Description (optional)
* @param string|null $description
* @return \Pimcore\Model\DataObject\Teaser
*/
public function setDescription ($description, $language = null)
{
$isEqual = false;
$this->getLocalizedfields()->setLocalizedValue("description", $description, $language, !$isEqual);
return $this;
}
/**
* Set page - Page
* @param \Pimcore\Model\Document\Page | \Pimcore\Model\Document\Link|null $page
* @return \Pimcore\Model\DataObject\Teaser
*/
public function setPage ($page, $language = null)
{
$fd = $this->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition("page");
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getPage($language);
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
$isEqual = $fd->isEqual($currentData, $page);
if (!$isEqual) {
$this->markFieldDirty("page", true);
}
$this->getLocalizedfields()->setLocalizedValue("page", $page, $language, !$isEqual);
return $this;
}
/**
* Set linkText - Link Text
* @param string|null $linkText
* @return \Pimcore\Model\DataObject\Teaser
*/
public function setLinkText ($linkText, $language = null)
{
$isEqual = false;
$this->getLocalizedfields()->setLocalizedValue("linkText", $linkText, $language, !$isEqual);
return $this;
}
}