var/classes/DataObject/Teaser.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * Inheritance: no
  4.  * Variants: no
  5.  *
  6.  * Fields Summary:
  7.  * - teaserCategories [manyToManyObjectRelation]
  8.  * - teaserImage [image]
  9.  * - localizedfields [localizedfields]
  10.  * -- title [input]
  11.  * -- description [textarea]
  12.  * -- page [manyToOneRelation]
  13.  * -- linkText [input]
  14.  */
  15. namespace Pimcore\Model\DataObject;
  16. use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
  17. use Pimcore\Model\DataObject\PreGetValueHookInterface;
  18. /**
  19. * @method static \Pimcore\Model\DataObject\Teaser\Listing getList(array $config = [])
  20. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTeaserCategories($value, $limit = 0, $offset = 0, $objectTypes = null)
  21. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTeaserImage($value, $limit = 0, $offset = 0, $objectTypes = null)
  22. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLocalizedfields($field, $value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  23. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTitle($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  24. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByDescription($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  25. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByPage($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  26. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLinkText($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  27. */
  28. class Teaser extends Concrete
  29. {
  30. protected $o_classId "teaser";
  31. protected $o_className "Teaser";
  32. protected $teaserCategories;
  33. protected $teaserImage;
  34. protected $localizedfields;
  35. /**
  36. * @param array $values
  37. * @return \Pimcore\Model\DataObject\Teaser
  38. */
  39. public static function create($values = array()) {
  40.     $object = new static();
  41.     $object->setValues($values);
  42.     return $object;
  43. }
  44. /**
  45. * Get teaserCategories - Teaser Categories
  46. * @return \Pimcore\Model\DataObject\TeaserCategory[]
  47. */
  48. public function getTeaserCategories()
  49. {
  50.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  51.         $preValue $this->preGetValue("teaserCategories");
  52.         if ($preValue !== null) {
  53.             return $preValue;
  54.         }
  55.     }
  56.     $data $this->getClass()->getFieldDefinition("teaserCategories")->preGetData($this);
  57.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  58.         return $data->getPlain();
  59.     }
  60.     return $data;
  61. }
  62. /**
  63. * Set teaserCategories - Teaser Categories
  64. * @param \Pimcore\Model\DataObject\TeaserCategory[] $teaserCategories
  65. * @return \Pimcore\Model\DataObject\Teaser
  66. */
  67. public function setTeaserCategories($teaserCategories)
  68. {
  69.     /** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToManyObjectRelation $fd */
  70.     $fd $this->getClass()->getFieldDefinition("teaserCategories");
  71.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  72.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  73.     $currentData $this->getTeaserCategories();
  74.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  75.     $isEqual $fd->isEqual($currentData$teaserCategories);
  76.     if (!$isEqual) {
  77.         $this->markFieldDirty("teaserCategories"true);
  78.     }
  79.     $this->teaserCategories $fd->preSetData($this$teaserCategories);
  80.     return $this;
  81. }
  82. /**
  83. * Get teaserImage - Teaser Image
  84. * @return \Pimcore\Model\Asset\Image|null
  85. */
  86. public function getTeaserImage()
  87. {
  88.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  89.         $preValue $this->preGetValue("teaserImage");
  90.         if ($preValue !== null) {
  91.             return $preValue;
  92.         }
  93.     }
  94.     $data $this->teaserImage;
  95.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  96.         return $data->getPlain();
  97.     }
  98.     return $data;
  99. }
  100. /**
  101. * Set teaserImage - Teaser Image
  102. * @param \Pimcore\Model\Asset\Image|null $teaserImage
  103. * @return \Pimcore\Model\DataObject\Teaser
  104. */
  105. public function setTeaserImage($teaserImage)
  106. {
  107.     $this->teaserImage $teaserImage;
  108.     return $this;
  109. }
  110. /**
  111. * Get localizedfields - 
  112. * @return \Pimcore\Model\DataObject\Localizedfield|null
  113. */
  114. public function getLocalizedfields()
  115. {
  116.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  117.         $preValue $this->preGetValue("localizedfields");
  118.         if ($preValue !== null) {
  119.             return $preValue;
  120.         }
  121.     }
  122.     $data $this->getClass()->getFieldDefinition("localizedfields")->preGetData($this);
  123.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  124.         return $data->getPlain();
  125.     }
  126.     return $data;
  127. }
  128. /**
  129. * Get title - Title (optional)
  130. * @return string|null
  131. */
  132. public function getTitle($language null)
  133. {
  134.     $data $this->getLocalizedfields()->getLocalizedValue("title"$language);
  135.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  136.         $preValue $this->preGetValue("title");
  137.         if ($preValue !== null) {
  138.             return $preValue;
  139.         }
  140.     }
  141.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  142.         return $data->getPlain();
  143.     }
  144.     return $data;
  145. }
  146. /**
  147. * Get description - Description (optional)
  148. * @return string|null
  149. */
  150. public function getDescription($language null)
  151. {
  152.     $data $this->getLocalizedfields()->getLocalizedValue("description"$language);
  153.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  154.         $preValue $this->preGetValue("description");
  155.         if ($preValue !== null) {
  156.             return $preValue;
  157.         }
  158.     }
  159.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  160.         return $data->getPlain();
  161.     }
  162.     return $data;
  163. }
  164. /**
  165. * Get page - Page
  166. * @return \Pimcore\Model\Document\Page | \Pimcore\Model\Document\Link|null
  167. */
  168. public function getPage($language null)
  169. {
  170.     $data $this->getLocalizedfields()->getLocalizedValue("page"$language);
  171.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  172.         $preValue $this->preGetValue("page");
  173.         if ($preValue !== null) {
  174.             return $preValue;
  175.         }
  176.     }
  177.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  178.         return $data->getPlain();
  179.     }
  180.     return $data;
  181. }
  182. /**
  183. * Get linkText - Link Text
  184. * @return string|null
  185. */
  186. public function getLinkText($language null)
  187. {
  188.     $data $this->getLocalizedfields()->getLocalizedValue("linkText"$language);
  189.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  190.         $preValue $this->preGetValue("linkText");
  191.         if ($preValue !== null) {
  192.             return $preValue;
  193.         }
  194.     }
  195.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  196.         return $data->getPlain();
  197.     }
  198.     return $data;
  199. }
  200. /**
  201. * Set localizedfields - 
  202. * @param \Pimcore\Model\DataObject\Localizedfield|null $localizedfields
  203. * @return \Pimcore\Model\DataObject\Teaser
  204. */
  205. public function setLocalizedfields($localizedfields)
  206. {
  207.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  208.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  209.     $currentData $this->getLocalizedfields();
  210.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  211.     $this->markFieldDirty("localizedfields"true);
  212.     $this->localizedfields $localizedfields;
  213.     return $this;
  214. }
  215. /**
  216. * Set title - Title (optional)
  217. * @param string|null $title
  218. * @return \Pimcore\Model\DataObject\Teaser
  219. */
  220. public function setTitle ($title$language null)
  221. {
  222.     $isEqual false;
  223.     $this->getLocalizedfields()->setLocalizedValue("title"$title$language, !$isEqual);
  224.     return $this;
  225. }
  226. /**
  227. * Set description - Description (optional)
  228. * @param string|null $description
  229. * @return \Pimcore\Model\DataObject\Teaser
  230. */
  231. public function setDescription ($description$language null)
  232. {
  233.     $isEqual false;
  234.     $this->getLocalizedfields()->setLocalizedValue("description"$description$language, !$isEqual);
  235.     return $this;
  236. }
  237. /**
  238. * Set page - Page
  239. * @param \Pimcore\Model\Document\Page | \Pimcore\Model\Document\Link|null $page
  240. * @return \Pimcore\Model\DataObject\Teaser
  241. */
  242. public function setPage ($page$language null)
  243. {
  244.     $fd $this->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition("page");
  245.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  246.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  247.     $currentData $this->getPage($language);
  248.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  249.     $isEqual $fd->isEqual($currentData$page);
  250.     if (!$isEqual) {
  251.         $this->markFieldDirty("page"true);
  252.     }
  253.     $this->getLocalizedfields()->setLocalizedValue("page"$page$language, !$isEqual);
  254.     return $this;
  255. }
  256. /**
  257. * Set linkText - Link Text
  258. * @param string|null $linkText
  259. * @return \Pimcore\Model\DataObject\Teaser
  260. */
  261. public function setLinkText ($linkText$language null)
  262. {
  263.     $isEqual false;
  264.     $this->getLocalizedfields()->setLocalizedValue("linkText"$linkText$language, !$isEqual);
  265.     return $this;
  266. }
  267. }