custom/plugins/GbmedEnev/src/Core/Content/Enev/EnevCollection.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * gb media
  4.  * All Rights Reserved.
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited.
  7.  * The content of this file is proprietary and confidential.
  8.  *
  9.  * @category       Shopware
  10.  * @package        Shopware_Plugins
  11.  * @subpackage     GbmedEnev
  12.  * @copyright      Copyright (c) 2019, gb media
  13.  * @license        proprietary
  14.  * @author         Giuseppe Bottino
  15.  * @link           http://www.gb-media.biz
  16.  */
  17. namespace Gbmed\Enev\Core\Content\Enev;
  18. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  19. /**
  20.  * @method void              add(EnevEntity $entity)
  21.  * @method void              set(string $key, EnevEntity $entity)
  22.  * @method EnevEntity[]    getIterator()
  23.  * @method EnevEntity[]    getElements()
  24.  * @method EnevEntity|null get(string $key)
  25.  * @method EnevEntity|null first()
  26.  * @method EnevEntity|null last()
  27.  */
  28. class EnevCollection extends EntityCollection
  29. {
  30.     /**
  31.      * return entity class name
  32.      *
  33.      * @return string
  34.      */
  35.     protected function getExpectedClass(): string
  36.     {
  37.         return EnevEntity::class;
  38.     }
  39.     public function getActiveElements(): array
  40.     {
  41.         /** @var EnevEntity $element */
  42.         return array_filter($this->getElements(), function ($element) {
  43.             return $element->getActive();
  44.         });
  45.     }
  46.     public function hasActiveElements(): bool
  47.     {
  48.         return count($this->getActiveElements()) > 0;
  49.     }
  50. }