var/classes/DataObject/News.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3.  * Inheritance: no
  4.  * Variants: no
  5.  *
  6.  * Fields Summary:
  7.  * - date [date]
  8.  * - headline [textarea]
  9.  * - intro [textarea]
  10.  * - download [link]
  11.  * - content [fieldcollections]
  12.  * - teaserImage [manyToOneRelation]
  13.  */
  14. namespace Pimcore\Model\DataObject;
  15. use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
  16. use Pimcore\Model\DataObject\PreGetValueHookInterface;
  17. /**
  18. * @method static \Pimcore\Model\DataObject\News\Listing getList(array $config = [])
  19. * @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByDate($value, $limit = 0, $offset = 0, $objectTypes = null)
  20. * @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByHeadline($value, $limit = 0, $offset = 0, $objectTypes = null)
  21. * @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByIntro($value, $limit = 0, $offset = 0, $objectTypes = null)
  22. * @method static \Pimcore\Model\DataObject\News\Listing|\Pimcore\Model\DataObject\News|null getByTeaserImage($value, $limit = 0, $offset = 0, $objectTypes = null)
  23. */
  24. class News extends Concrete
  25. {
  26. protected $o_classId "News";
  27. protected $o_className "News";
  28. protected $date;
  29. protected $headline;
  30. protected $intro;
  31. protected $download;
  32. protected $content;
  33. protected $teaserImage;
  34. /**
  35. * @param array $values
  36. * @return \Pimcore\Model\DataObject\News
  37. */
  38. public static function create($values = array()) {
  39.     $object = new static();
  40.     $object->setValues($values);
  41.     return $object;
  42. }
  43. /**
  44. * Get date - Date
  45. * @return \Carbon\Carbon|null
  46. */
  47. public function getDate(): ?\Carbon\Carbon
  48. {
  49.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  50.         $preValue $this->preGetValue("date");
  51.         if ($preValue !== null) {
  52.             return $preValue;
  53.         }
  54.     }
  55.     $data $this->date;
  56.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  57.         return $data->getPlain();
  58.     }
  59.     return $data;
  60. }
  61. /**
  62. * Set date - Date
  63. * @param \Carbon\Carbon|null $date
  64. * @return \Pimcore\Model\DataObject\News
  65. */
  66. public function setDate(?\Carbon\Carbon $date)
  67. {
  68.     $this->date $date;
  69.     return $this;
  70. }
  71. /**
  72. * Get headline - Headline
  73. * @return string|null
  74. */
  75. public function getHeadline(): ?string
  76. {
  77.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  78.         $preValue $this->preGetValue("headline");
  79.         if ($preValue !== null) {
  80.             return $preValue;
  81.         }
  82.     }
  83.     $data $this->headline;
  84.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  85.         return $data->getPlain();
  86.     }
  87.     return $data;
  88. }
  89. /**
  90. * Set headline - Headline
  91. * @param string|null $headline
  92. * @return \Pimcore\Model\DataObject\News
  93. */
  94. public function setHeadline(?string $headline)
  95. {
  96.     $this->headline $headline;
  97.     return $this;
  98. }
  99. /**
  100. * Get intro - Intro
  101. * @return string|null
  102. */
  103. public function getIntro(): ?string
  104. {
  105.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  106.         $preValue $this->preGetValue("intro");
  107.         if ($preValue !== null) {
  108.             return $preValue;
  109.         }
  110.     }
  111.     $data $this->intro;
  112.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  113.         return $data->getPlain();
  114.     }
  115.     return $data;
  116. }
  117. /**
  118. * Set intro - Intro
  119. * @param string|null $intro
  120. * @return \Pimcore\Model\DataObject\News
  121. */
  122. public function setIntro(?string $intro)
  123. {
  124.     $this->intro $intro;
  125.     return $this;
  126. }
  127. /**
  128. * Get download - Download
  129. * @return \Pimcore\Model\DataObject\Data\Link|null
  130. */
  131. public function getDownload(): ?\Pimcore\Model\DataObject\Data\Link
  132. {
  133.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  134.         $preValue $this->preGetValue("download");
  135.         if ($preValue !== null) {
  136.             return $preValue;
  137.         }
  138.     }
  139.     $data $this->download;
  140.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  141.         return $data->getPlain();
  142.     }
  143.     return $data;
  144. }
  145. /**
  146. * Set download - Download
  147. * @param \Pimcore\Model\DataObject\Data\Link|null $download
  148. * @return \Pimcore\Model\DataObject\News
  149. */
  150. public function setDownload(?\Pimcore\Model\DataObject\Data\Link $download)
  151. {
  152.     $this->download $download;
  153.     return $this;
  154. }
  155. /**
  156. * @return \Pimcore\Model\DataObject\Fieldcollection|null
  157. */
  158. public function getContent(): ?\Pimcore\Model\DataObject\Fieldcollection
  159. {
  160.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  161.         $preValue $this->preGetValue("content");
  162.         if ($preValue !== null) {
  163.             return $preValue;
  164.         }
  165.     }
  166.     $data $this->getClass()->getFieldDefinition("content")->preGetData($this);
  167.     return $data;
  168. }
  169. /**
  170. * Set content - Content
  171. * @param \Pimcore\Model\DataObject\Fieldcollection|null $content
  172. * @return \Pimcore\Model\DataObject\News
  173. */
  174. public function setContent(?\Pimcore\Model\DataObject\Fieldcollection $content)
  175. {
  176.     /** @var \Pimcore\Model\DataObject\ClassDefinition\Data\Fieldcollections $fd */
  177.     $fd $this->getClass()->getFieldDefinition("content");
  178.     $this->content $fd->preSetData($this$content);
  179.     return $this;
  180. }
  181. /**
  182. * Get teaserImage - Teaser Image
  183. * @return \Pimcore\Model\Asset\Image|null
  184. */
  185. public function getTeaserImage(): ?\Pimcore\Model\Element\AbstractElement
  186. {
  187.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  188.         $preValue $this->preGetValue("teaserImage");
  189.         if ($preValue !== null) {
  190.             return $preValue;
  191.         }
  192.     }
  193.     $data $this->getClass()->getFieldDefinition("teaserImage")->preGetData($this);
  194.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  195.         return $data->getPlain();
  196.     }
  197.     return $data;
  198. }
  199. /**
  200. * Set teaserImage - Teaser Image
  201. * @param \Pimcore\Model\Asset\Image|null $teaserImage
  202. * @return \Pimcore\Model\DataObject\News
  203. */
  204. public function setTeaserImage(?\Pimcore\Model\Element\AbstractElement $teaserImage)
  205. {
  206.     /** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToOneRelation $fd */
  207.     $fd $this->getClass()->getFieldDefinition("teaserImage");
  208.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  209.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  210.     $currentData $this->getTeaserImage();
  211.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  212.     $isEqual $fd->isEqual($currentData$teaserImage);
  213.     if (!$isEqual) {
  214.         $this->markFieldDirty("teaserImage"true);
  215.     }
  216.     $this->teaserImage $fd->preSetData($this$teaserImage);
  217.     return $this;
  218. }
  219. }