vendor/shopware/core/System/Language/LanguageCollection.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\System\Language;
  3. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  4. use Shopware\Core\System\Locale\LocaleCollection;
  5. /**
  6.  * @method void                add(LanguageEntity $entity)
  7.  * @method void                set(string $key, LanguageEntity $entity)
  8.  * @method LanguageEntity[]    getIterator()
  9.  * @method LanguageEntity[]    getElements()
  10.  * @method LanguageEntity|null get(string $key)
  11.  * @method LanguageEntity|null first()
  12.  * @method LanguageEntity|null last()
  13.  */
  14. class LanguageCollection extends EntityCollection
  15. {
  16.     public function getParentIds(): array
  17.     {
  18.         return $this->fmap(function (LanguageEntity $language) {
  19.             return $language->getParentId();
  20.         });
  21.     }
  22.     public function filterByParentId(string $id): LanguageCollection
  23.     {
  24.         return $this->filter(function (LanguageEntity $language) use ($id) {
  25.             return $language->getParentId() === $id;
  26.         });
  27.     }
  28.     public function getLocaleIds(): array
  29.     {
  30.         return $this->fmap(function (LanguageEntity $language) {
  31.             return $language->getLocaleId();
  32.         });
  33.     }
  34.     public function filterByLocaleId(string $id): LanguageCollection
  35.     {
  36.         return $this->filter(function (LanguageEntity $language) use ($id) {
  37.             return $language->getLocaleId() === $id;
  38.         });
  39.     }
  40.     public function getLocales(): LocaleCollection
  41.     {
  42.         return new LocaleCollection(
  43.             $this->fmap(function (LanguageEntity $language) {
  44.                 return $language->getLocale();
  45.             })
  46.         );
  47.     }
  48.     public function getApiAlias(): string
  49.     {
  50.         return 'language_collection';
  51.     }
  52.     protected function getExpectedClass(): string
  53.     {
  54.         return LanguageEntity::class;
  55.     }
  56. }