var/classes/DataObject/Teaser.php line 30

Open in your IDE?
  1. <?php
  2. /**
  3. * Inheritance: no
  4. * Variants: no
  5. Fields Summary:
  6. - image [image]
  7. - localizedfields [localizedfields]
  8. -- title [input]
  9. -- text [textarea]
  10. -- link [link]
  11. */
  12. namespace Pimcore\Model\DataObject;
  13. use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
  14. use Pimcore\Model\DataObject\PreGetValueHookInterface;
  15. /**
  16. * @method static \Pimcore\Model\DataObject\Teaser\Listing getList()
  17. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByImage($value, $limit = 0, $offset = 0, $objectTypes = null)
  18. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLocalizedfields($field, $value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  19. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByTitle($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  20. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByText($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  21. * @method static \Pimcore\Model\DataObject\Teaser\Listing|\Pimcore\Model\DataObject\Teaser|null getByLink($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  22. */
  23. class Teaser extends Concrete
  24. {
  25. protected $o_classId = "1";
  26. protected $o_className = "Teaser";
  27. protected $image;
  28. protected $localizedfields;
  29. /**
  30. * @param array $values
  31. * @return \Pimcore\Model\DataObject\Teaser
  32. */
  33. public static function create($values = array()) {
  34.     $object = new static();
  35.     $object->setValues($values);
  36.     return $object;
  37. }
  38. /**
  39. * Get image - Bild
  40. * @return \Pimcore\Model\Asset\Image|null
  41. */
  42. public function getImage()
  43. {
  44.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  45.         $preValue = $this->preGetValue("image");
  46.         if ($preValue !== null) {
  47.             return $preValue;
  48.         }
  49.     }
  50.     $data = $this->image;
  51.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  52.         return $data->getPlain();
  53.     }
  54.     return $data;
  55. }
  56. /**
  57. * Set image - Bild
  58. * @param \Pimcore\Model\Asset\Image|null $image
  59. * @return \Pimcore\Model\DataObject\Teaser
  60. */
  61. public function setImage($image)
  62. {
  63.     $this->image = $image;
  64.     return $this;
  65. }
  66. /**
  67. * Get localizedfields - 
  68. * @return \Pimcore\Model\DataObject\Localizedfield|null
  69. */
  70. public function getLocalizedfields()
  71. {
  72.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  73.         $preValue = $this->preGetValue("localizedfields");
  74.         if ($preValue !== null) {
  75.             return $preValue;
  76.         }
  77.     }
  78.     $data = $this->getClass()->getFieldDefinition("localizedfields")->preGetData($this);
  79.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  80.         return $data->getPlain();
  81.     }
  82.     return $data;
  83. }
  84. /**
  85. * Get title - Titel
  86. * @return string|null
  87. */
  88. public function getTitle($language = null)
  89. {
  90.     $data = $this->getLocalizedfields()->getLocalizedValue("title", $language);
  91.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  92.         $preValue = $this->preGetValue("title");
  93.         if ($preValue !== null) {
  94.             return $preValue;
  95.         }
  96.     }
  97.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  98.         return $data->getPlain();
  99.     }
  100.     return $data;
  101. }
  102. /**
  103. * Get text - Text
  104. * @return string|null
  105. */
  106. public function getText($language = null)
  107. {
  108.     $data = $this->getLocalizedfields()->getLocalizedValue("text", $language);
  109.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  110.         $preValue = $this->preGetValue("text");
  111.         if ($preValue !== null) {
  112.             return $preValue;
  113.         }
  114.     }
  115.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  116.         return $data->getPlain();
  117.     }
  118.     return $data;
  119. }
  120. /**
  121. * Get link - Link
  122. * @return \Pimcore\Model\DataObject\Data\Link|null
  123. */
  124. public function getLink($language = null)
  125. {
  126.     $data = $this->getLocalizedfields()->getLocalizedValue("link", $language);
  127.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  128.         $preValue = $this->preGetValue("link");
  129.         if ($preValue !== null) {
  130.             return $preValue;
  131.         }
  132.     }
  133.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  134.         return $data->getPlain();
  135.     }
  136.     return $data;
  137. }
  138. /**
  139. * Set localizedfields - 
  140. * @param \Pimcore\Model\DataObject\Localizedfield|null $localizedfields
  141. * @return \Pimcore\Model\DataObject\Teaser
  142. */
  143. public function setLocalizedfields($localizedfields)
  144. {
  145.     $hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  146.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  147.     $currentData = $this->getLocalizedfields();
  148.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  149.     $this->markFieldDirty("localizedfields", true);
  150.     $this->localizedfields = $localizedfields;
  151.     return $this;
  152. }
  153. /**
  154. * Set title - Titel
  155. * @param string|null $title
  156. * @return \Pimcore\Model\DataObject\Teaser
  157. */
  158. public function setTitle ($title, $language = null)
  159. {
  160.     $isEqual = false;
  161.     $this->getLocalizedfields()->setLocalizedValue("title", $title, $language, !$isEqual);
  162.     return $this;
  163. }
  164. /**
  165. * Set text - Text
  166. * @param string|null $text
  167. * @return \Pimcore\Model\DataObject\Teaser
  168. */
  169. public function setText ($text, $language = null)
  170. {
  171.     $isEqual = false;
  172.     $this->getLocalizedfields()->setLocalizedValue("text", $text, $language, !$isEqual);
  173.     return $this;
  174. }
  175. /**
  176. * Set link - Link
  177. * @param \Pimcore\Model\DataObject\Data\Link|null $link
  178. * @return \Pimcore\Model\DataObject\Teaser
  179. */
  180. public function setLink ($link, $language = null)
  181. {
  182.     $isEqual = false;
  183.     $this->getLocalizedfields()->setLocalizedValue("link", $link, $language, !$isEqual);
  184.     return $this;
  185. }
  186. }