-
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.
- Loading branch information
Showing
15 changed files
with
306 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use LRuozzi9\SyliusElasticsearchPlugin\Factory\ProductResponseFactory; | ||
use LRuozzi9\SyliusElasticsearchPlugin\Model\ProductResponse; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator) { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services->set('lruozzi9.sylius_elasticsearch_plugin.factory.product_response', ProductResponseFactory::class) | ||
->args([ | ||
ProductResponse::class, | ||
]) | ||
; | ||
}; |
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use LRuozzi9\SyliusElasticsearchPlugin\Parser\ElasticsearchProductDocumentParser; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator) { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services->set('lruozzi9.sylius_elasticsearch_plugin.parser.elasticsearch_document', ElasticsearchProductDocumentParser::class) | ||
->args([ | ||
service('lruozzi9.sylius_elasticsearch_plugin.factory.product_response'), | ||
service('sylius.context.locale'), | ||
service('sylius.context.channel'), | ||
param('sylius_locale.locale'), | ||
]) | ||
; | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LRuozzi9\SyliusElasticsearchPlugin\Factory; | ||
|
||
use LRuozzi9\SyliusElasticsearchPlugin\Model\ProductResponseInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final readonly class ProductResponseFactory implements ProductResponseFactoryInterface | ||
{ | ||
/** | ||
* @param class-string $responseClass | ||
*/ | ||
public function __construct( | ||
private string $responseClass, | ||
) { | ||
} | ||
|
||
/** | ||
* @psalm-suppress MixedMethodCall | ||
*/ | ||
public function createNew(): ProductResponseInterface | ||
{ | ||
$response = new $this->responseClass(); | ||
Assert::isInstanceOf($response, ProductResponseInterface::class); | ||
|
||
return $response; | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LRuozzi9\SyliusElasticsearchPlugin\Factory; | ||
|
||
use LRuozzi9\SyliusElasticsearchPlugin\Model\ProductResponseInterface; | ||
|
||
interface ProductResponseFactoryInterface | ||
{ | ||
public function createNew(): ProductResponseInterface; | ||
} |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LRuozzi9\SyliusElasticsearchPlugin\Model; | ||
|
||
abstract class AbstractResponse implements ResponseInterface | ||
{ | ||
private ?string $routeName = null; | ||
|
||
/** @var array<string, mixed>|null */ | ||
private ?array $routeParams = null; | ||
|
||
public function getRouteName(): ?string | ||
{ | ||
return $this->routeName; | ||
} | ||
|
||
public function setRouteName(?string $routeName): void | ||
{ | ||
$this->routeName = $routeName; | ||
} | ||
|
||
public function getRouteParams(): ?array | ||
{ | ||
return $this->routeParams; | ||
} | ||
|
||
public function setRouteParams(?array $routeParams): void | ||
{ | ||
$this->routeParams = $routeParams; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LRuozzi9\SyliusElasticsearchPlugin\Parser; | ||
|
||
use LRuozzi9\SyliusElasticsearchPlugin\Model\ResponseInterface; | ||
|
||
interface DocumentParserInterface | ||
{ | ||
/** | ||
* @param array{_index: string, _id: string, score: float, _source: array} $document | ||
*/ | ||
public function parse(array $document): ResponseInterface; | ||
} |
Oops, something went wrong.