getPackagers example


    public function __construct(private readonly LineItemGroupServiceRegistry $serviceRegistry)
    {
    }

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

        /** @var LineItemGroupPackagerInterface $packager */
        foreach ($this->serviceRegistry->getPackagers() as $packager) {
            $packagerKeys[] = $packager->getKey();
        }

        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 = [];

        

    public function testPackagersAreRegistered(): void
    {
        $packagers = [
            new LineItemGroupCountPackager(),
            new LineItemGroupUnitPriceNetPackager(),
        ];
        $sorters = [];

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

        $generator = iterator_to_array($registry->getPackagers());
        static::assertCount(2, $generator);
    }

    /** * This test verifies that our sorters are * correctly registered in our registry. */
    public function testSortersAreRegistered(): void
    {
        $packagers = [];
        $sorters = [
            
Home | Imprint | This part of the site doesn't use cookies.