Skip to content

Commit

Permalink
Change to provider instead of factory, move trait
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 24, 2024
1 parent e942605 commit 322c625
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 22 deletions.
7 changes: 0 additions & 7 deletions config/factories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,5 @@ services:
public: false

#Factory

Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceFactoryInterface:
class: Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceFactory

Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceLoaderInterface:
class: Pimcore\Bundle\StudioApiBundle\Factory\Loader\TaggedIteratorAdapter

Pimcore\Bundle\StudioApiBundle\Factory\QueryFactoryInterface:
class: Pimcore\Bundle\StudioApiBundle\Factory\QueryFactory
13 changes: 13 additions & 0 deletions config/providers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

#Factory

Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceProviderInterface:
class: Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceProvider

Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceLoaderInterface:
class: Pimcore\Bundle\StudioApiBundle\Provider\Loader\TaggedIteratorAdapter
6 changes: 3 additions & 3 deletions src/Controller/Api/Assets/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
use Pimcore\Bundle\StudioApiBundle\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioApiBundle\Config\Tags;
use Pimcore\Bundle\StudioApiBundle\Controller\Api\AbstractApiController;
use Pimcore\Bundle\StudioApiBundle\Controller\Trait\PaginatedResponseTrait;
use Pimcore\Bundle\StudioApiBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceFactoryInterface;
use Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceProviderInterface;
use Pimcore\Bundle\StudioApiBundle\Request\Query\Filter\ElementParameters;
use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchServiceInterface;
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Filter\OpenSearchFilterInterface;
use Pimcore\Bundle\StudioApiBundle\Util\Traits\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
Expand All @@ -56,7 +56,7 @@ final class CollectionController extends AbstractApiController
public function __construct(
SerializerInterface $serializer,
private readonly AssetSearchServiceInterface $assetSearchService,
private readonly FilterServiceFactoryInterface $filterServiceFactory
private readonly FilterServiceProviderInterface $filterServiceFactory
) {
parent::__construct($serializer);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Api/DataObjects/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
use Pimcore\Bundle\StudioApiBundle\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioApiBundle\Config\Tags;
use Pimcore\Bundle\StudioApiBundle\Controller\Api\AbstractApiController;
use Pimcore\Bundle\StudioApiBundle\Controller\Trait\PaginatedResponseTrait;
use Pimcore\Bundle\StudioApiBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceFactoryInterface;
use Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceProviderInterface;
use Pimcore\Bundle\StudioApiBundle\Request\Query\Filter\DataObjectParameters;
use Pimcore\Bundle\StudioApiBundle\Service\DataObjectSearchServiceInterface;
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Filter\OpenSearchFilterInterface;
use Pimcore\Bundle\StudioApiBundle\Util\Traits\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
Expand All @@ -54,7 +54,7 @@ final class CollectionController extends AbstractApiController
public function __construct(
SerializerInterface $serializer,
private readonly DataObjectSearchServiceInterface $dataObjectSearchService,
private readonly FilterServiceFactoryInterface $filterServiceFactory
private readonly FilterServiceProviderInterface $filterServiceFactory
) {
parent::__construct($serializer);
}
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/PimcoreStudioApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('event_subscribers.yaml');
$loader->load('factories.yaml');
$loader->load('filters.yaml');
$loader->load('providers.yaml');
$loader->load('services.yaml');

$definition = $container->getDefinition(TokenServiceInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioApiBundle\Factory;
namespace Pimcore\Bundle\StudioApiBundle\Provider;

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioApiBundle\Factory;
namespace Pimcore\Bundle\StudioApiBundle\Provider;

use Pimcore\Bundle\StudioApiBundle\Exception\InvalidFilterServiceTypeException;

final class FilterServiceFactory implements FilterServiceFactoryInterface
final class FilterServiceProvider implements FilterServiceProviderInterface
{
private array $filterServices = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioApiBundle\Factory;
namespace Pimcore\Bundle\StudioApiBundle\Provider;

interface FilterServiceFactoryInterface
interface FilterServiceProviderInterface
{
public function create(string $type): mixed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioApiBundle\Factory\Loader;

use Pimcore\Bundle\StudioApiBundle\Factory\FilterServiceLoaderInterface;
namespace Pimcore\Bundle\StudioApiBundle\Provider\Loader;

use Pimcore\Bundle\StudioApiBundle\Provider\FilterServiceLoaderInterface;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioApiBundle\Controller\Trait;
namespace Pimcore\Bundle\StudioApiBundle\Util\Traits;

use Pimcore\Bundle\StudioApiBundle\Response\Collection;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down

0 comments on commit 322c625

Please sign in to comment.