|  | 
| 18 | 18 | use Ibexa\AdminUi\Form\Factory\FormFactory; | 
| 19 | 19 | use Ibexa\AdminUi\Form\SubmitHandler; | 
| 20 | 20 | use Ibexa\AdminUi\Form\Type\ContentType\ContentTypeUpdateType; | 
|  | 21 | +use Ibexa\AdminUi\Pagination\Pagerfanta\ContentTypeListAdapter; | 
| 21 | 22 | use Ibexa\AdminUi\Service\MetaFieldType\MetaFieldDefinitionServiceInterface; | 
| 22 | 23 | use Ibexa\AdminUi\Tab\ContentType\TranslationsTab; | 
| 23 | 24 | use Ibexa\AdminUi\UI\Module\FieldTypeToolbar\FieldTypeToolbarFactory; | 
|  | 
| 36 | 37 | use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; | 
| 37 | 38 | use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft; | 
| 38 | 39 | use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup; | 
|  | 40 | +use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\ContentTypeQuery; | 
|  | 41 | +use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContentTypeGroupId; | 
|  | 42 | +use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Name; | 
| 39 | 43 | use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; | 
| 40 | 44 | use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; | 
| 41 | 45 | use JMS\TranslationBundle\Annotation\Desc; | 
| 42 |  | -use Pagerfanta\Adapter\ArrayAdapter; | 
| 43 | 46 | use Pagerfanta\Pagerfanta; | 
| 44 | 47 | use Symfony\Component\Form\FormInterface; | 
| 45 | 48 | use Symfony\Component\HttpFoundation\RedirectResponse; | 
| @@ -132,32 +135,31 @@ public function __construct( | 
| 132 | 135 |     public function listAction(ContentTypeGroup $group, string $routeName, int $page): Response | 
| 133 | 136 |     { | 
| 134 | 137 |         $deletableTypes = []; | 
| 135 |  | -        $contentTypes = $this->contentTypeService->loadContentTypes($group, $this->configResolver->getParameter('languages')); | 
| 136 |  | - | 
| 137 |  | -        usort($contentTypes, static function (ContentType $contentType1, ContentType $contentType2) { | 
| 138 |  | -            return strnatcasecmp($contentType1->getName(), $contentType2->getName()); | 
| 139 |  | -        }); | 
|  | 138 | +        $languages = $this->configResolver->getParameter('languages'); | 
|  | 139 | +        $limit = $this->configResolver->getParameter('pagination.content_type_limit'); | 
|  | 140 | +        $query = new ContentTypeQuery(new ContentTypeGroupId($group->id), [new Name()]); | 
| 140 | 141 | 
 | 
| 141 | 142 |         $pagerfanta = new Pagerfanta( | 
| 142 |  | -            new ArrayAdapter($contentTypes) | 
|  | 143 | +            new ContentTypeListAdapter($this->contentTypeService, $languages, $query) | 
| 143 | 144 |         ); | 
| 144 | 145 | 
 | 
| 145 |  | -        $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.content_type_limit')); | 
|  | 146 | +        $pagerfanta->setMaxPerPage($limit); | 
| 146 | 147 |         $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); | 
| 147 | 148 | 
 | 
| 148 |  | -        /** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[] $contentTypeGroupList */ | 
| 149 | 149 |         $types = $pagerfanta->getCurrentPageResults(); | 
| 150 | 150 | 
 | 
| 151 | 151 |         $deleteContentTypesForm = $this->formFactory->deleteContentTypes( | 
| 152 |  | -            new ContentTypesDeleteData($this->getContentTypesNumbers($types)) | 
|  | 152 | +            new ContentTypesDeleteData($this->getContentTypesNumbers( | 
|  | 153 | +                \Ibexa\PolyfillPhp82\iterator_to_array($types) | 
|  | 154 | +            )) | 
| 153 | 155 |         ); | 
| 154 | 156 | 
 | 
| 155 | 157 |         foreach ($types as $type) { | 
| 156 | 158 |             $deletableTypes[$type->id] = !$this->contentTypeService->isContentTypeUsed($type); | 
| 157 | 159 |         } | 
| 158 | 160 | 
 | 
| 159 | 161 |         $copyData = new ContentTypeCopyData(null, $group); | 
| 160 |  | -        $contentTypeCopyForm = $this->contentTypeFormFactory->contentTypeCopy($copyData, null)->createView(); | 
|  | 162 | +        $contentTypeCopyForm = $this->contentTypeFormFactory->contentTypeCopy($copyData)->createView(); | 
| 161 | 163 | 
 | 
| 162 | 164 |         return $this->render('@ibexadesign/content_type/list.html.twig', [ | 
| 163 | 165 |             'content_type_group' => $group, | 
|  | 
0 commit comments