vendor/pimcore/pimcore/models/Document/Listing.php line 32

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\Document;
  15. use Pimcore\Model;
  16. use Pimcore\Model\Document;
  17. use Pimcore\Model\Paginator\PaginateListingInterface;
  18. /**
  19.  * @method Document[] load()
  20.  * @method Document current()
  21.  * @method int getTotalCount()
  22.  * @method int getCount()
  23.  * @method int[] loadIdList()
  24.  * @method \Pimcore\Model\Document\Listing\Dao getDao()
  25.  * @method onCreateQueryBuilder(?callable $callback)
  26.  * @method array loadIdPathList()
  27.  */
  28. class Listing extends Model\Listing\AbstractListing implements PaginateListingInterface
  29. {
  30.     /**
  31.      * Return all documents as Type Document. eg. for trees an so on there isn't the whole data required
  32.      *
  33.      * @internal
  34.      *
  35.      * @var bool
  36.      */
  37.     protected $objectTypeDocument false;
  38.     /**
  39.      * @internal
  40.      *
  41.      * @var bool
  42.      */
  43.     protected $unpublished false;
  44.     /**
  45.      * @return Document[]
  46.      */
  47.     public function getDocuments()
  48.     {
  49.         return $this->getData();
  50.     }
  51.     /**
  52.      * @param array $documents
  53.      *
  54.      * @return Listing
  55.      */
  56.     public function setDocuments($documents)
  57.     {
  58.         return $this->setData($documents);
  59.     }
  60.     /**
  61.      * Checks if the document is unpublished.
  62.      *
  63.      * @return bool
  64.      */
  65.     public function getUnpublished()
  66.     {
  67.         return $this->unpublished;
  68.     }
  69.     /**
  70.      * Set the unpublished flag for the document.
  71.      *
  72.      * @param bool $unpublished
  73.      *
  74.      * @return $this
  75.      */
  76.     public function setUnpublished($unpublished)
  77.     {
  78.         $this->unpublished = (bool) $unpublished;
  79.         return $this;
  80.     }
  81.     /**
  82.      * {@inheritdoc}
  83.      */
  84.     public function getCondition()
  85.     {
  86.         $condition parent::getCondition();
  87.         if ($condition) {
  88.             if (Document::doHideUnpublished() && !$this->getUnpublished()) {
  89.                 $condition ' (' $condition ') AND published = 1';
  90.             }
  91.         } elseif (Document::doHideUnpublished() && !$this->getUnpublished()) {
  92.             $condition 'published = 1';
  93.         }
  94.         return $condition;
  95.     }
  96.     /**
  97.      *
  98.      * Methods for AdapterInterface
  99.      */
  100.     /**
  101.      * {@inheritdoc}
  102.      */
  103.     public function count()
  104.     {
  105.         return $this->getTotalCount();
  106.     }
  107.     /**
  108.      * {@inheritdoc}
  109.      */
  110.     public function getItems($offset$itemCountPerPage)
  111.     {
  112.         $this->setOffset($offset);
  113.         $this->setLimit($itemCountPerPage);
  114.         return $this->load();
  115.     }
  116. }