var/classes/DataObject/Download.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3.  * Inheritance: no
  4.  * Variants: no
  5.  *
  6.  * Fields Summary:
  7.  * - title [input]
  8.  * - description [textarea]
  9.  * - pdf [manyToOneRelation]
  10.  */
  11. namespace Pimcore\Model\DataObject;
  12. use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
  13. use Pimcore\Model\DataObject\PreGetValueHookInterface;
  14. /**
  15. * @method static \Pimcore\Model\DataObject\Download\Listing getList(array $config = [])
  16. * @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByTitle($value, $limit = 0, $offset = 0, $objectTypes = null)
  17. * @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByDescription($value, $limit = 0, $offset = 0, $objectTypes = null)
  18. * @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByPdf($value, $limit = 0, $offset = 0, $objectTypes = null)
  19. */
  20. class Download extends Concrete
  21. {
  22. protected $o_classId "Download";
  23. protected $o_className "Download";
  24. protected $title;
  25. protected $description;
  26. protected $pdf;
  27. /**
  28. * @param array $values
  29. * @return \Pimcore\Model\DataObject\Download
  30. */
  31. public static function create($values = array()) {
  32.     $object = new static();
  33.     $object->setValues($values);
  34.     return $object;
  35. }
  36. /**
  37. * Get title - Title
  38. * @return string|null
  39. */
  40. public function getTitle(): ?string
  41. {
  42.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  43.         $preValue $this->preGetValue("title");
  44.         if ($preValue !== null) {
  45.             return $preValue;
  46.         }
  47.     }
  48.     $data $this->title;
  49.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  50.         return $data->getPlain();
  51.     }
  52.     return $data;
  53. }
  54. /**
  55. * Set title - Title
  56. * @param string|null $title
  57. * @return \Pimcore\Model\DataObject\Download
  58. */
  59. public function setTitle(?string $title)
  60. {
  61.     $this->title $title;
  62.     return $this;
  63. }
  64. /**
  65. * Get description - Description
  66. * @return string|null
  67. */
  68. public function getDescription(): ?string
  69. {
  70.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  71.         $preValue $this->preGetValue("description");
  72.         if ($preValue !== null) {
  73.             return $preValue;
  74.         }
  75.     }
  76.     $data $this->description;
  77.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  78.         return $data->getPlain();
  79.     }
  80.     return $data;
  81. }
  82. /**
  83. * Set description - Description
  84. * @param string|null $description
  85. * @return \Pimcore\Model\DataObject\Download
  86. */
  87. public function setDescription(?string $description)
  88. {
  89.     $this->description $description;
  90.     return $this;
  91. }
  92. /**
  93. * Get pdf - Pdf
  94. * @return \Pimcore\Model\Asset\Document|null
  95. */
  96. public function getPdf(): ?\Pimcore\Model\Element\AbstractElement
  97. {
  98.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  99.         $preValue $this->preGetValue("pdf");
  100.         if ($preValue !== null) {
  101.             return $preValue;
  102.         }
  103.     }
  104.     $data $this->getClass()->getFieldDefinition("pdf")->preGetData($this);
  105.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  106.         return $data->getPlain();
  107.     }
  108.     return $data;
  109. }
  110. /**
  111. * Set pdf - Pdf
  112. * @param \Pimcore\Model\Asset\Document|null $pdf
  113. * @return \Pimcore\Model\DataObject\Download
  114. */
  115. public function setPdf(?\Pimcore\Model\Element\AbstractElement $pdf)
  116. {
  117.     /** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToOneRelation $fd */
  118.     $fd $this->getClass()->getFieldDefinition("pdf");
  119.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  120.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  121.     $currentData $this->getPdf();
  122.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  123.     $isEqual $fd->isEqual($currentData$pdf);
  124.     if (!$isEqual) {
  125.         $this->markFieldDirty("pdf"true);
  126.     }
  127.     $this->pdf $fd->preSetData($this$pdf);
  128.     return $this;
  129. }
  130. }