ECS applied

This commit is contained in:
kuba-end
2021-12-06 15:01:48 +01:00
parent 51a2b1edc2
commit 4ad5bc4128
130 changed files with 272 additions and 88 deletions

View File

@@ -8,7 +8,8 @@
"php": "^7.3 || ^7.4",
"sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0",
"friendsofsymfony/elastica-bundle": "^5.0",
"symfony/property-access": "^4.4 || ^5.2"
"symfony/property-access": "^4.4 || ^5.2",
"bitbag/coding-standard": "^1.0"
},
"require-dev": {
"behat/behat": "^3.6.1",

16
ecs.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
};

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin;
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Block;
use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
@@ -31,7 +32,11 @@ final class SearchFormEventListener
/** @var FormInterface */
private $form;
public function __construct(string $template, FormFactoryInterface $formFactory, RouterInterface $router)
public function __construct(
string $template,
FormFactoryInterface $formFactory,
RouterInterface $router
)
{
$this->template = $template;
$this->formFactory = $formFactory;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
interface ProductAttributesContextInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductOptionsFinderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
interface ProductOptionsContextInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Exception\TaxonNotFoundException;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use Sylius\Component\Core\Model\TaxonInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Api;
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\DataHandlerInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
use BitBag\SyliusElasticsearchPlugin\Block\SearchFormEventListener;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface DataHandlerInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
final class PaginationDataHandler implements PaginationDataHandlerInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface PaginationDataHandlerInterface extends DataHandlerInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
use BitBag\SyliusElasticsearchPlugin\Exception\TaxonNotFoundException;
@@ -127,7 +128,11 @@ final class ShopProductListDataHandler implements DataHandlerInterface
return $data;
}
private function reformatAttributeArrayValues(array $attributeValues, string $property, array $attributesDefinitions): array
private function reformatAttributeArrayValues(
array $attributeValues,
string $property,
array $attributesDefinitions
): array
{
$reformattedValues = [];
foreach ($attributeValues as $attributeValue) {

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
use BitBag\SyliusElasticsearchPlugin\Context\TaxonContextInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface SortDataHandlerInterface extends DataHandlerInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO;
final class Item

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response;
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\DependencyInjection;
use Symfony\Component\Config\FileLocator;

View File

@@ -8,14 +8,10 @@
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
use BitBag\SyliusElasticsearchPlugin\Refresher\ResourceRefresherInterface;
use Sylius\Component\Core\Model\ProductTaxonInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Webmozart\Assert\Assert;
final class ProductTaxonIndexListener
{

View File

@@ -8,7 +8,6 @@
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
use BitBag\SyliusElasticsearchPlugin\Refresher\ResourceRefresherInterface;

View File

@@ -8,7 +8,6 @@
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
use Symfony\Component\EventDispatcher\GenericEvent;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Exception;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -71,9 +72,11 @@ final class AttributeFacet implements FacetInterface
private function getFieldName(): string
{
return \sprintf('%s_%s.keyword',
return \sprintf(
'%s_%s.keyword',
$this->attributeNameResolver->resolvePropertyName($this->attributeCode),
$this->localeContext->getLocaleCode());
$this->localeContext->getLocaleCode()
);
}
private function getProductAttribute(): AttributeInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use Elastica\Aggregation\AbstractAggregation;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
class FacetNotFoundException extends \RuntimeException

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
final class Registry implements RegistryInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
interface RegistryInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use Elastica\Aggregation\AbstractAggregation;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
interface NamedProductsFinderInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Sylius\Component\Core\Model\TaxonInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Sylius\Component\Core\Model\TaxonInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\PaginationDataHandlerInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Pagerfanta\Pagerfanta;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use Symfony\Component\Form\AbstractType;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use Sylius\Component\Product\Model\ProductAttributeInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use Sylius\Component\Product\Model\ProductOptionInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use Symfony\Component\Form\Extension\Core\Type\TextType;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\PriceNameResolverInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Context\ProductAttributesContextInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Context\ProductOptionsContextInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Model\SearchBox;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
final class StringFormatter implements StringFormatterInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
interface StringFormatterInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
use Sylius\Component\Core\Model\ProductInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
use Sylius\Component\Core\Model\ProductInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
class Search

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
class SearchBox

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
class SearchFacets implements \Iterator
@@ -34,7 +35,7 @@ class SearchFacets implements \Iterator
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function current()
{
@@ -42,7 +43,7 @@ class SearchFacets implements \Iterator
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function next()
{
@@ -50,7 +51,7 @@ class SearchFacets implements \Iterator
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function key()
{
@@ -58,17 +59,17 @@ class SearchFacets implements \Iterator
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function valid()
{
$key = key($this->selectedBuckets);
return $key !== null && $key !== false;
return null !== $key && false !== $key;
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function rewind()
{

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use FOS\ElasticaBundle\Event\TransformEvent;
@@ -14,7 +15,11 @@ use Sylius\Component\Resource\Model\ToggleableInterface;
abstract class AbstractBuilder implements PropertyBuilderInterface
{
public function buildProperty(TransformEvent $event, string $supportedModelClass, callable $callback): void
public function buildProperty(
TransformEvent $event,
string $supportedModelClass,
callable $callback
): void
{
$model = $event->getObject();

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
@@ -35,10 +36,13 @@ final class AttributeBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$this->resolveProductAttributes($product, $document);
});
}
);
}
private function resolveProductAttributes(ProductInterface $product, Document $document): void
@@ -54,9 +58,13 @@ final class AttributeBuilder extends AbstractBuilder
}
}
private function resolveProductAttribute(array $attributeConfiguration, $attributeValue, AttributeTranslation $attribute): array
private function resolveProductAttribute(
array $attributeConfiguration,
$attributeValue,
AttributeTranslation $attribute
): array
{
if ($attribute->getTranslatable()->getType() === 'select') {
if ('select' === $attribute->getTranslatable()->getType()) {
$choices = $attributeConfiguration['choices'];
if (is_array($attributeValue)) {
foreach ($attributeValue as $i => $item) {
@@ -80,7 +88,11 @@ final class AttributeBuilder extends AbstractBuilder
return $attributes;
}
private function processAttribute(AttributeInterface $attribute, $productAttribute, Document $document): void
private function processAttribute(
AttributeInterface $attribute,
$productAttribute,
Document $document
): void
{
$attributeCode = $attribute->getCode();
$attributeConfiguration = $attribute->getConfiguration();

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Repository\TaxonRepositoryInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -27,7 +28,9 @@ final class ChannelPricingBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
if (0 === $product->getVariants()->count()) {
return;
@@ -41,6 +44,7 @@ final class ChannelPricingBuilder extends AbstractBuilder
$document->set($propertyName, $channelPricing->getPrice());
}
});
}
);
}
}

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use Elastica\Document;
@@ -25,7 +26,9 @@ final class ChannelsBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$channels = [];

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper;
use Sylius\Component\Core\Model\ProductInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper;
use Sylius\Component\Core\Model\ProductInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
@@ -31,10 +32,13 @@ final class OptionBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$this->resolveProductOptions($product, $document);
});
}
);
}
private function resolveProductOptions(ProductInterface $product, Document $document): void

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use Elastica\Document;
@@ -19,7 +20,9 @@ final class ProductCodeBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$document->set(self::PROPERTY_NAME, $product->getCode());
}

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use Elastica\Document;
@@ -25,7 +26,9 @@ final class ProductCreatedAtPropertyBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$createdAt = (int) $product->getCreatedAt()->format('U');

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -27,7 +28,9 @@ final class ProductDescriptionBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -27,7 +28,9 @@ final class ProductNameBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -27,7 +28,9 @@ final class ProductShortDescriptionBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -26,7 +27,9 @@ final class ProductTaxonPositionPropertyBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
foreach ($product->getProductTaxons() as $taxon) {
$document->set(

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
@@ -30,7 +31,9 @@ final class ProductTaxonsBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$taxons = $this->productTaxonsMapper->mapToUniqueCodes($product);

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use FOS\ElasticaBundle\Event\TransformEvent;
@@ -16,5 +17,9 @@ interface PropertyBuilderInterface extends EventSubscriberInterface
{
public function consumeEvent(TransformEvent $event): void;
public function buildProperty(TransformEvent $event, string $class, callable $callback): void;
public function buildProperty(
TransformEvent $event,
string $class,
callable $callback
): void;
}

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Repository\OrderItemRepositoryInterface;
@@ -30,7 +31,9 @@ final class SoldUnitsPropertyBuilder extends AbstractBuilder
public function consumeEvent(TransformEvent $event): void
{
$this->buildProperty($event, ProductInterface::class,
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$soldUnits = 0;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class ConcatedNameResolver implements ConcatedNameResolverInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface ConcatedNameResolverInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class PriceNameResolver implements PriceNameResolverInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface PriceNameResolverInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class SearchPropertyNameResolverRegistry implements SearchPropertyNameResolverRegistryInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface SearchPropertyNameResolverRegistryInterface

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
@@ -62,7 +63,7 @@ final class HasPriceBetweenQueryBuilder implements QueryBuilderInterface
$propertyName = $this->channelPricingNameResolver->resolvePropertyName($channelCode);
$rangeQuery = new Range();
$paramValue = $this->getQueryParamValue($minPrice , $maxPrice);
$paramValue = $this->getQueryParamValue($minPrice, $maxPrice);
if (null === $paramValue) {
return null;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\SearchPropertyNameResolverRegistryInterface;

View File

@@ -7,6 +7,7 @@
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use Elastica\Query\AbstractQuery;

Some files were not shown because too many files have changed in this diff Show More