vendor/pimcore/pimcore/models/DataObject/Data/ImageGallery.php line 21

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\Data;
  15. use Pimcore\Model\DataObject\OwnerAwareFieldInterface;
  16. use Pimcore\Model\DataObject\Traits\OwnerAwareFieldTrait;
  17. class ImageGallery implements \IteratorOwnerAwareFieldInterface
  18. {
  19.     use OwnerAwareFieldTrait;
  20.     /**
  21.      * @var Hotspotimage[]
  22.      */
  23.     protected $items;
  24.     /**
  25.      * @param Hotspotimage[] $items
  26.      */
  27.     public function __construct($items = [])
  28.     {
  29.         $this->setItems($items);
  30.         $this->markMeDirty();
  31.     }
  32.     /**
  33.      * @return Hotspotimage|bool|null
  34.      */
  35.     #[\ReturnTypeWillChange]
  36.     public function current()// : Hotspotimage|false
  37.     {
  38.         return current($this->items);
  39.     }
  40.     /**
  41.      * @return void
  42.      */
  43.     #[\ReturnTypeWillChange]
  44.     public function next()// : void
  45.     {
  46.         next($this->items);
  47.     }
  48.     /**
  49.      * @return int|string|null
  50.      */
  51.     #[\ReturnTypeWillChange]
  52.     public function key()// : mixed
  53.     {
  54.         return key($this->items);
  55.     }
  56.     /**
  57.      * @return bool
  58.      */
  59.     #[\ReturnTypeWillChange]
  60.     public function valid()// : bool
  61.     {
  62.         return $this->current() !== false;
  63.     }
  64.     /**
  65.      * @return void
  66.      */
  67.     #[\ReturnTypeWillChange]
  68.     public function rewind()// : void
  69.     {
  70.         reset($this->items);
  71.     }
  72.     /**
  73.      * @return Hotspotimage[]
  74.      */
  75.     public function getItems()
  76.     {
  77.         return $this->items;
  78.     }
  79.     /**
  80.      * @param Hotspotimage[] $items
  81.      */
  82.     public function setItems($items)
  83.     {
  84.         if (!is_array($items)) {
  85.             $items = [];
  86.         }
  87.         $this->items $items;
  88.         $this->rewind();
  89.         $this->markMeDirty();
  90.     }
  91.     /**
  92.      * @return bool
  93.      */
  94.     public function hasValidImages(): bool
  95.     {
  96.         foreach ($this->getItems() as $item) {
  97.             if ($item instanceof \Pimcore\Model\DataObject\Data\Hotspotimage) {
  98.                 return true;
  99.             }
  100.         }
  101.         return false;
  102.     }
  103. }