var/classes/DataObject/News.php line 32

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