<?php
/**
* Inheritance: no
* Variants: no
*
* Fields Summary:
* - title [input]
* - description [textarea]
* - pdf [manyToOneRelation]
*/
namespace Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
use Pimcore\Model\DataObject\PreGetValueHookInterface;
/**
* @method static \Pimcore\Model\DataObject\Download\Listing getList(array $config = [])
* @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByTitle($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByDescription($value, $limit = 0, $offset = 0, $objectTypes = null)
* @method static \Pimcore\Model\DataObject\Download\Listing|\Pimcore\Model\DataObject\Download|null getByPdf($value, $limit = 0, $offset = 0, $objectTypes = null)
*/
class Download extends Concrete
{
protected $o_classId = "Download";
protected $o_className = "Download";
protected $title;
protected $description;
protected $pdf;
/**
* @param array $values
* @return \Pimcore\Model\DataObject\Download
*/
public static function create($values = array()) {
$object = new static();
$object->setValues($values);
return $object;
}
/**
* Get title - Title
* @return string|null
*/
public function getTitle(): ?string
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("title");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->title;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set title - Title
* @param string|null $title
* @return \Pimcore\Model\DataObject\Download
*/
public function setTitle(?string $title)
{
$this->title = $title;
return $this;
}
/**
* Get description - Description
* @return string|null
*/
public function getDescription(): ?string
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("description");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->description;
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set description - Description
* @param string|null $description
* @return \Pimcore\Model\DataObject\Download
*/
public function setDescription(?string $description)
{
$this->description = $description;
return $this;
}
/**
* Get pdf - Pdf
* @return \Pimcore\Model\Asset\Document|null
*/
public function getPdf(): ?\Pimcore\Model\Element\AbstractElement
{
if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
$preValue = $this->preGetValue("pdf");
if ($preValue !== null) {
return $preValue;
}
}
$data = $this->getClass()->getFieldDefinition("pdf")->preGetData($this);
if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
return $data->getPlain();
}
return $data;
}
/**
* Set pdf - Pdf
* @param \Pimcore\Model\Asset\Document|null $pdf
* @return \Pimcore\Model\DataObject\Download
*/
public function setPdf(?\Pimcore\Model\Element\AbstractElement $pdf)
{
/** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToOneRelation $fd */
$fd = $this->getClass()->getFieldDefinition("pdf");
$hideUnpublished = \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
$currentData = $this->getPdf();
\Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
$isEqual = $fd->isEqual($currentData, $pdf);
if (!$isEqual) {
$this->markFieldDirty("pdf", true);
}
$this->pdf = $fd->preSetData($this, $pdf);
return $this;
}
}