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

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|false 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_OBJECTModel\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 $this
  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.      * @return $this
  90.      */
  91.     public function resetConditionParams()
  92.     {
  93.         return parent::resetConditionParams(); // TODO: Change the autogenerated stub
  94.     }
  95.     /**
  96.      * @param string $condition
  97.      * @param array|scalar $conditionVariables
  98.      *
  99.      * @return $this
  100.      */
  101.     public function setCondition($condition$conditionVariables null)
  102.     {
  103.         return parent::setCondition($condition$conditionVariables);
  104.     }
  105.     /**
  106.      *
  107.      * Methods for AdapterInterface
  108.      */
  109.     /**
  110.      * @return int
  111.      */
  112.     #[\ReturnTypeWillChange]
  113.     public function count()// : int
  114.     {
  115.         return $this->getDao()->getTotalCount();
  116.     }
  117.     /**
  118.      * {@inheritdoc}
  119.      */
  120.     public function getItems($offset$itemCountPerPage)
  121.     {
  122.         $this->setOffset($offset);
  123.         $this->setLimit($itemCountPerPage);
  124.         return $this->load();
  125.     }
  126.     /**
  127.      * @internal
  128.      *
  129.      * @return bool
  130.      */
  131.     public function addDistinct()
  132.     {
  133.         return false;
  134.     }
  135.     /**
  136.      * @internal
  137.      *
  138.      * @param string $field database column to use for WHERE condition
  139.      * @param string $operator SQL comparison operator, e.g. =, <, >= etc. You can use "?" as placeholder, e.g. "IN (?)"
  140.      * @param string|int|float|array $data comparison data, can be scalar or array (if operator is e.g. "IN (?)")
  141.      *
  142.      * @return $this
  143.      */
  144.     public function addFilterByField($field$operator$data)
  145.     {
  146.         if (strpos($operator'?') === false) {
  147.             $operator .= ' ?';
  148.         }
  149.         return $this->addConditionParam('`'.$field.'` '.$operator$data);
  150.     }
  151. }