var/classes/DataObject/Category.php line 178

Open in your IDE?
  1. <?php
  2. /**
  3.  * Inheritance: yes
  4.  * Variants: no
  5.  *
  6.  * Fields Summary:
  7.  * - localizedfields [localizedfields]
  8.  * -- name [input]
  9.  * -- productNamePart [input]
  10.  * - filterDefinition [manyToOneRelation]
  11.  * - cars [reverseObjectRelation]
  12.  */
  13. namespace Pimcore\Model\DataObject;
  14. use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
  15. use Pimcore\Model\DataObject\PreGetValueHookInterface;
  16. /**
  17. * @method static \Pimcore\Model\DataObject\Category\Listing getList(array $config = [])
  18. * @method static \Pimcore\Model\DataObject\Category\Listing|\Pimcore\Model\DataObject\Category|null getByLocalizedfields($field, $value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  19. * @method static \Pimcore\Model\DataObject\Category\Listing|\Pimcore\Model\DataObject\Category|null getByName($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  20. * @method static \Pimcore\Model\DataObject\Category\Listing|\Pimcore\Model\DataObject\Category|null getByProductNamePart($value, $locale = null, $limit = 0, $offset = 0, $objectTypes = null)
  21. * @method static \Pimcore\Model\DataObject\Category\Listing|\Pimcore\Model\DataObject\Category|null getByFilterDefinition($value, $limit = 0, $offset = 0, $objectTypes = null)
  22. * @method static \Pimcore\Model\DataObject\Category\Listing|\Pimcore\Model\DataObject\Category|null getByCars($value, $limit = 0, $offset = 0, $objectTypes = null)
  23. */
  24. class Category extends \Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory
  25. {
  26. protected $o_classId "CA";
  27. protected $o_className "Category";
  28. protected $localizedfields;
  29. protected $filterDefinition;
  30. /**
  31. * @param array $values
  32. * @return \Pimcore\Model\DataObject\Category
  33. */
  34. public static function create($values = array()) {
  35.     $object = new static();
  36.     $object->setValues($values);
  37.     return $object;
  38. }
  39. /**
  40. * Get localizedfields - Texts
  41. * @return \Pimcore\Model\DataObject\Localizedfield|null
  42. */
  43. public function getLocalizedfields(): ?\Pimcore\Model\DataObject\Localizedfield
  44. {
  45.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  46.         $preValue $this->preGetValue("localizedfields");
  47.         if ($preValue !== null) {
  48.             return $preValue;
  49.         }
  50.     }
  51.     $data $this->getClass()->getFieldDefinition("localizedfields")->preGetData($this);
  52.     if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("localizedfields")->isEmpty($data)) {
  53.         try {
  54.             return $this->getValueFromParent("localizedfields");
  55.         } catch (InheritanceParentNotFoundException $e) {
  56.             // no data from parent available, continue ...
  57.         }
  58.     }
  59.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  60.         return $data->getPlain();
  61.     }
  62.     return $data;
  63. }
  64. /**
  65. * Get name - Name
  66. * @return string|null
  67. */
  68. public function getName($language null): ?string
  69. {
  70.     $data $this->getLocalizedfields()->getLocalizedValue("name"$language);
  71.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  72.         $preValue $this->preGetValue("name");
  73.         if ($preValue !== null) {
  74.             return $preValue;
  75.         }
  76.     }
  77.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  78.         return $data->getPlain();
  79.     }
  80.     return $data;
  81. }
  82. /**
  83. * Get productNamePart - Product Name Part
  84. * @return string|null
  85. */
  86. public function getProductNamePart($language null): ?string
  87. {
  88.     $data $this->getLocalizedfields()->getLocalizedValue("productNamePart"$language);
  89.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  90.         $preValue $this->preGetValue("productNamePart");
  91.         if ($preValue !== null) {
  92.             return $preValue;
  93.         }
  94.     }
  95.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  96.         return $data->getPlain();
  97.     }
  98.     return $data;
  99. }
  100. /**
  101. * Set localizedfields - Texts
  102. * @param \Pimcore\Model\DataObject\Localizedfield|null $localizedfields
  103. * @return \Pimcore\Model\DataObject\Category
  104. */
  105. public function setLocalizedfields(?\Pimcore\Model\DataObject\Localizedfield $localizedfields)
  106. {
  107.     $inheritValues self::getGetInheritedValues();
  108.     self::setGetInheritedValues(false);
  109.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  110.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  111.     $currentData $this->getLocalizedfields();
  112.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  113.     self::setGetInheritedValues($inheritValues);
  114.     $this->markFieldDirty("localizedfields"true);
  115.     $this->localizedfields $localizedfields;
  116.     return $this;
  117. }
  118. /**
  119. * Set name - Name
  120. * @param string|null $name
  121. * @return \Pimcore\Model\DataObject\Category
  122. */
  123. public function setName (?string $name$language null)
  124. {
  125.     $isEqual false;
  126.     $this->getLocalizedfields()->setLocalizedValue("name"$name$language, !$isEqual);
  127.     return $this;
  128. }
  129. /**
  130. * Set productNamePart - Product Name Part
  131. * @param string|null $productNamePart
  132. * @return \Pimcore\Model\DataObject\Category
  133. */
  134. public function setProductNamePart (?string $productNamePart$language null)
  135. {
  136.     $isEqual false;
  137.     $this->getLocalizedfields()->setLocalizedValue("productNamePart"$productNamePart$language, !$isEqual);
  138.     return $this;
  139. }
  140. /**
  141. * Get filterDefinition - Filter Definition
  142. * @return \Pimcore\Model\DataObject\FilterDefinition|null
  143. */
  144. public function getFilterDefinition(): ?\Pimcore\Model\Element\AbstractElement
  145. {
  146.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  147.         $preValue $this->preGetValue("filterDefinition");
  148.         if ($preValue !== null) {
  149.             return $preValue;
  150.         }
  151.     }
  152.     $data $this->getClass()->getFieldDefinition("filterDefinition")->preGetData($this);
  153.     if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("filterDefinition")->isEmpty($data)) {
  154.         try {
  155.             return $this->getValueFromParent("filterDefinition");
  156.         } catch (InheritanceParentNotFoundException $e) {
  157.             // no data from parent available, continue ...
  158.         }
  159.     }
  160.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  161.         return $data->getPlain();
  162.     }
  163.     return $data;
  164. }
  165. /**
  166. * Set filterDefinition - Filter Definition
  167. * @param \Pimcore\Model\DataObject\FilterDefinition|null $filterDefinition
  168. * @return \Pimcore\Model\DataObject\Category
  169. */
  170. public function setFilterDefinition(?\Pimcore\Model\Element\AbstractElement $filterDefinition)
  171. {
  172.     /** @var \Pimcore\Model\DataObject\ClassDefinition\Data\ManyToOneRelation $fd */
  173.     $fd $this->getClass()->getFieldDefinition("filterDefinition");
  174.     $inheritValues self::getGetInheritedValues();
  175.     self::setGetInheritedValues(false);
  176.     $hideUnpublished \Pimcore\Model\DataObject\Concrete::getHideUnpublished();
  177.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished(false);
  178.     $currentData $this->getFilterDefinition();
  179.     \Pimcore\Model\DataObject\Concrete::setHideUnpublished($hideUnpublished);
  180.     self::setGetInheritedValues($inheritValues);
  181.     $isEqual $fd->isEqual($currentData$filterDefinition);
  182.     if (!$isEqual) {
  183.         $this->markFieldDirty("filterDefinition"true);
  184.     }
  185.     $this->filterDefinition $fd->preSetData($this$filterDefinition);
  186.     return $this;
  187. }
  188. /**
  189. * Get cars - Cars
  190. * @return \Pimcore\Model\DataObject\AbstractObject[]
  191. */
  192. public function getCars(): array
  193. {
  194.     if ($this instanceof PreGetValueHookInterface && !\Pimcore::inAdmin()) {
  195.         $preValue $this->preGetValue("cars");
  196.         if ($preValue !== null) {
  197.             return $preValue;
  198.         }
  199.     }
  200.     $data $this->getClass()->getFieldDefinition("cars")->preGetData($this);
  201.     if ($data instanceof \Pimcore\Model\DataObject\Data\EncryptedField) {
  202.         return $data->getPlain();
  203.     }
  204.     return $data;
  205. }
  206. }