vendor/pimcore/pimcore/models/DataObject/Listing.php line 143

Open in your IDE?
  1. <?php
  2. /**
  3. * Pimcore
  4. *
  5. * This source file is available under two different licenses:
  6. * - GNU General Public License version 3 (GPLv3)
  7. * - Pimcore Commercial License (PCL)
  8. * Full copyright and license information is available in
  9. * LICENSE.md which is distributed with this source code.
  10. *
  11. * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12. * @license http://www.pimcore.org/license GPLv3 and PCL
  13. */
  14. namespace Pimcore\Model\DataObject;
  15. use Pimcore\Model;
  16. use Pimcore\Model\Paginator\PaginateListingInterface;
  17. /**
  18. * @method Model\DataObject[] load()
  19. * @method Model\DataObject current()
  20. * @method int getTotalCount()
  21. * @method int getCount()
  22. * @method int[] loadIdList()
  23. * @method \Pimcore\Model\DataObject\Listing\Dao getDao()
  24. * @method onCreateQueryBuilder(?callable $callback)
  25. */
  26. class Listing extends Model\Listing\AbstractListing implements PaginateListingInterface
  27. {
  28. /**
  29. * @var bool
  30. */
  31. protected $unpublished = false;
  32. /**
  33. * @var array
  34. */
  35. protected $objectTypes = [Model\DataObject::OBJECT_TYPE_OBJECT, Model\DataObject::OBJECT_TYPE_FOLDER];
  36. /**
  37. * @return array
  38. */
  39. public function getObjects()
  40. {
  41. return $this->getData();
  42. }
  43. /**
  44. * @param array $objects
  45. *
  46. * @return static
  47. */
  48. public function setObjects($objects)
  49. {
  50. return $this->setData($objects);
  51. }
  52. /**
  53. * @return bool
  54. */
  55. public function getUnpublished()
  56. {
  57. return $this->unpublished;
  58. }
  59. /**
  60. * @param bool $unpublished
  61. *
  62. * @return $this
  63. */
  64. public function setUnpublished($unpublished)
  65. {
  66. $this->setData(null);
  67. $this->unpublished = (bool) $unpublished;
  68. return $this;
  69. }
  70. /**
  71. * @param array $objectTypes
  72. *
  73. * @return $this
  74. */
  75. public function setObjectTypes($objectTypes)
  76. {
  77. $this->setData(null);
  78. $this->objectTypes = $objectTypes;
  79. return $this;
  80. }
  81. /**
  82. * @return array
  83. */
  84. public function getObjectTypes()
  85. {
  86. return $this->objectTypes;
  87. }
  88. /**
  89. * @param string $key
  90. * @param mixed $value
  91. * @param string $concatenator
  92. *
  93. * @return $this
  94. */
  95. public function addConditionParam($key, $value = null, $concatenator = 'AND')
  96. {
  97. return parent::addConditionParam($key, $value, $concatenator); // TODO: Change the autogenerated stub
  98. }
  99. /**
  100. * @return $this
  101. */
  102. public function resetConditionParams()
  103. {
  104. return parent::resetConditionParams(); // TODO: Change the autogenerated stub
  105. }
  106. /**
  107. * @param string $condition
  108. * @param array|scalar $conditionVariables
  109. *
  110. * @return $this
  111. */
  112. public function setCondition($condition, $conditionVariables = null)
  113. {
  114. return parent::setCondition($condition, $conditionVariables);
  115. }
  116. /**
  117. *
  118. * Methods for AdapterInterface
  119. */
  120. /**
  121. * {@inheritdoc}
  122. */
  123. public function count()
  124. {
  125. return $this->getDao()->getTotalCount();
  126. }
  127. /**
  128. * {@inheritdoc}
  129. */
  130. public function getItems($offset, $itemCountPerPage)
  131. {
  132. $this->setOffset($offset);
  133. $this->setLimit($itemCountPerPage);
  134. return $this->load();
  135. }
  136. /**
  137. * @internal
  138. *
  139. * @return bool
  140. */
  141. public function addDistinct()
  142. {
  143. return false;
  144. }
  145. /**
  146. * @internal
  147. *
  148. * @param string $field database column to use for WHERE condition
  149. * @param string $operator SQL comparison operator, e.g. =, <, >= etc. You can use "?" as placeholder, e.g. "IN (?)"
  150. * @param string|int|float|array $data comparison data, can be scalar or array (if operator is e.g. "IN (?)")
  151. *
  152. * @return static
  153. */
  154. public function addFilterByField($field, $operator, $data)
  155. {
  156. if (strpos($operator, '?') === false) {
  157. $operator .= ' ?';
  158. }
  159. return $this->addConditionParam('`'.$field.'` '.$operator, $data);
  160. }
  161. }