mirror of
https://github.com/jbcr/SyliusElasticsearchPlugin.git
synced 2026-03-24 00:42:08 +01:00
ECS applied
This commit is contained in:
@@ -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
16
ecs.php
Normal 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',
|
||||
]);
|
||||
};
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
interface ProductAttributesContextInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Finder\ProductOptionsFinderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
interface ProductOptionsContextInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Exception\TaxonNotFoundException;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Context;
|
||||
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Api;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\DataHandlerInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Block\SearchFormEventListener;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
|
||||
|
||||
interface DataHandlerInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
|
||||
|
||||
final class PaginationDataHandler implements PaginationDataHandlerInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
|
||||
|
||||
interface PaginationDataHandlerInterface extends DataHandlerInterface
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Context\TaxonContextInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
|
||||
|
||||
interface SortDataHandlerInterface extends DataHandlerInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO;
|
||||
|
||||
final class Item
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Refresher\ResourceRefresherInterface;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
|
||||
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
use Elastica\Aggregation\AbstractAggregation;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
class FacetNotFoundException extends \RuntimeException
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
final class Registry implements RegistryInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
interface RegistryInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Facet;
|
||||
|
||||
use Elastica\Aggregation\AbstractAggregation;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
interface NamedProductsFinderInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\PaginationDataHandlerInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Finder;
|
||||
|
||||
use Pagerfanta\Pagerfanta;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
|
||||
|
||||
use Sylius\Component\Product\Model\ProductAttributeInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
|
||||
|
||||
use Sylius\Component\Product\Model\ProductOptionInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\PriceNameResolverInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Context\ProductAttributesContextInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Context\ProductOptionsContextInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Model\SearchBox;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
|
||||
|
||||
final class StringFormatter implements StringFormatterInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
|
||||
|
||||
interface StringFormatterInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Model;
|
||||
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Model;
|
||||
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Model;
|
||||
|
||||
class Search
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\Model;
|
||||
|
||||
class SearchBox
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\Repository\TaxonRepositoryInterface;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper;
|
||||
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper;
|
||||
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
final class ConcatedNameResolver implements ConcatedNameResolverInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
interface ConcatedNameResolverInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
final class PriceNameResolver implements PriceNameResolverInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
interface PriceNameResolverInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
final class SearchPropertyNameResolverRegistry implements SearchPropertyNameResolverRegistryInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
|
||||
|
||||
interface SearchPropertyNameResolverRegistryInterface
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use Elastica\Query\AbstractQuery;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
|
||||
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\SearchPropertyNameResolverRegistryInterface;
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user