LocaleCollection example


        $repository = $this->createMock(EntityRepository::class);

        $localeEntities = [];
        foreach ($locales as $locale) {
            $localeEntity = new LocaleEntity();
            $localeEntity->assign($locale);

            $localeEntities[] = $localeEntity;
        }

        $collection = new LocaleCollection($localeEntities);
        $entitySearchResult = new EntitySearchResult(
            LocaleDefinition::ENTITY_NAME,
            $collection->count(),
            $collection,
            null,
            new Criteria(),
            Context::createDefaultContext()
        );

        $repository
            ->method('search')
            

        return $this->fmap(fn (LanguageEntity $language) => $language->getLocaleId());
    }

    public function filterByLocaleId(string $id): LanguageCollection
    {
        return $this->filter(fn (LanguageEntity $language) => $language->getLocaleId() === $id);
    }

    public function getLocales(): LocaleCollection
    {
        return new LocaleCollection(
            $this->fmap(fn (LanguageEntity $language) => $language->getLocale())
        );
    }

    public function getApiAlias(): string
    {
        return 'language_collection';
    }

    protected function getExpectedClass(): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.