getSorters example



        return new JsonResponse($packagerKeys);
    }

    #[Route(path: '/api/_action/promotion/setgroup/sorter', name: 'api.action.promotion.setgroup.sorter', methods: ['GET'], defaults: ['_acl' => ['promotion:read']])]     public function getSetGroupSorters(): JsonResponse
    {
        $sorterKeys = [];

        /** @var LineItemGroupSorterInterface $sorter */
        foreach ($this->serviceRegistry->getSorters() as $sorter) {
            $sorterKeys[] = $sorter->getKey();
        }

        return new JsonResponse($sorterKeys);
    }
}

    public function testSortersAreRegistered(): void
    {
        $packagers = [];
        $sorters = [
            new LineItemGroupPriceAscSorter(),
        ];

        $registry = new LineItemGroupServiceRegistry($packagers$sorters);

        $generator = iterator_to_array($registry->getSorters());
        static::assertCount(1, $generator);
    }

    /** * This test verifies that we can retrieve * our packager by its key. * * @group lineitemgroup */
    public function testGetPackagerByKey(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.