-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shopsys] added Persoo bundle for product search (#2983)
- Loading branch information
Showing
32 changed files
with
665 additions
and
187 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/Component/Arguments/AbstractPaginatorArgumentsBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Component\Arguments; | ||
|
||
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface; | ||
|
||
class AbstractPaginatorArgumentsBuilder implements MappingInterface | ||
{ | ||
/** | ||
* @param array $config | ||
* @return array | ||
*/ | ||
public function toMappingDefinition(array $config): array | ||
{ | ||
return [ | ||
'after' => [ | ||
'type' => 'String', | ||
], | ||
'first' => [ | ||
'type' => 'Int', | ||
], | ||
'before' => [ | ||
'type' => 'String', | ||
], | ||
'last' => [ | ||
'type' => 'Int', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Component/Arguments/ProductPaginatorArgumentsBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Component\Arguments; | ||
|
||
class ProductPaginatorArgumentsBuilder extends AbstractProductPaginatorArgumentsBuilder | ||
{ | ||
/** | ||
* @param array $config | ||
* @return array | ||
*/ | ||
public function toMappingDefinition(array $config): array | ||
{ | ||
$this->checkMandatoryFields($config); | ||
|
||
$mappingDefinition = parent::toMappingDefinition($config); | ||
|
||
return array_merge($mappingDefinition, [ | ||
'categorySlug' => [ | ||
'type' => 'String', | ||
], | ||
'brandSlug' => [ | ||
'type' => 'String', | ||
], | ||
'flagSlug' => [ | ||
'type' => 'String', | ||
], | ||
]); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Component/Arguments/ProductSearchPaginatorArgumentsBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Component\Arguments; | ||
|
||
class ProductSearchPaginatorArgumentsBuilder extends AbstractProductPaginatorArgumentsBuilder | ||
{ | ||
/** | ||
* @param array $config | ||
* @return array | ||
*/ | ||
public function toMappingDefinition(array $config): array | ||
{ | ||
$this->checkMandatoryFields($config); | ||
|
||
$mappingDefinition = parent::toMappingDefinition($config); | ||
|
||
return array_merge($mappingDefinition, [ | ||
'search' => [ | ||
'type' => 'String', | ||
], | ||
]); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/DependencyInjection/RegisterProductsSearchResultsProvidersCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\DependencyInjection; | ||
|
||
use Shopsys\FrontendApiBundle\Model\Resolver\Products\Search\Exception\ProductSearchResultsProviderPriorityNotSetException; | ||
use Shopsys\FrontendApiBundle\Model\Resolver\Products\Search\ProductSearchResultsProviderResolver; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class RegisterProductsSearchResultsProvidersCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container | ||
*/ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
$productSearchResultsProviderResolverDefinition = $container->getDefinition(ProductSearchResultsProviderResolver::class); | ||
$productSearchResultsProvidersDefinitions = $container->findTaggedServiceIds('shopsys.frontend_api.products_search_results_provider'); | ||
|
||
foreach ($productSearchResultsProvidersDefinitions as $serviceId => $tags) { | ||
$priority = null; | ||
|
||
foreach ($tags as $tag) { | ||
if (array_key_exists('priority', $tag)) { | ||
$priority = $tag['priority']; | ||
} | ||
} | ||
|
||
if (!is_int($priority)) { | ||
throw new ProductSearchResultsProviderPriorityNotSetException(sprintf('Service "%s" has not defined required tag priority or its type is not integer.', $serviceId)); | ||
} | ||
|
||
$productSearchResultsProviderResolverDefinition->addMethodCall( | ||
'registerProductSearchResultsProvider', | ||
[ | ||
$serviceId, | ||
$priority, | ||
], | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.