Skip to content

Commit

Permalink
Upgrade to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GracjanJozefczyk committed Jan 7, 2025
1 parent dca1463 commit 7894209
Show file tree
Hide file tree
Showing 55 changed files with 2,111 additions and 690 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ARG PHP_VERSION=8.1
ARG PHP_VERSION=8.2
ENV LC_ALL=C.UTF-8

# Install basic tools
Expand All @@ -16,7 +16,7 @@ RUN apt-get update && apt-get install -y \
# Append NODE, NGINX and PHP repositories
RUN add-apt-repository ppa:ondrej/php \
&& add-apt-repository ppa:ondrej/nginx \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash -
&& curl -sL https://deb.nodesource.com/setup_20.x | bash -

# Install required PHP extensions
RUN apt-get update && apt-get install -y \
Expand Down
Empty file added assets/shop/entrypoint.js
Empty file.
32 changes: 16 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,46 @@
"description": "BitBag Elasticsearch plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"friendsofsymfony/elastica-bundle": "^6.0",
"sylius/sylius": "~1.13.0",
"symfony/property-access": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"symfony/proxy-manager-bridge": "^5.4 || ^6.0"
"sylius/sylius": "~2.0.0",
"symfony/property-access": "^6.4 || ^7.1",
"symfony/webpack-encore-bundle": "^2.2",
"symfony/proxy-manager-bridge": "^6.4 || ^7.1"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/behat": "^3.16",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^v2.0",
"dbrekelmans/bdi": "^1.1",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink": "^1.11",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/mink-debug-extension": "^2.0.0",
"friends-of-behat/mink-extension": "^2.4",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"league/flysystem-bundle": "2.4.0",
"lchrusciel/api-test-case": "^5.2",
"phpspec/phpspec": "^7.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8.1",
"phpstan/phpstan-doctrine": "1.3.69",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"phpunit/phpunit": "^10.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.2",
"sylius-labs/suite-tags-extension": "^0.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0"
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/dotenv": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1"
},
"conflict": {
"api-platform/core": "v2.7.17",
Expand All @@ -54,10 +53,11 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/thanks": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"php-http/discovery": false,
"phpstan/extension-installer": true,
"symfony/thanks": true
}
},
"extra": {
Expand Down
10 changes: 4 additions & 6 deletions src/Controller/Action/Shop/SiteWideProductsSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ public function __invoke(Request $request): Response
/** @var Search $search */
$search = $form->getData();

/** @var SearchBox $searchBox */
$searchBox = $search->getBox();

$data = array_merge(
['query' => $searchBox->getQuery()],
['query' => $search->getQuery()],
['facets' => $search->getFacets()],
$this->dataHandler->retrieveData($request->query->all()),
);
Expand All @@ -49,8 +46,9 @@ public function __invoke(Request $request): Response
return new Response($this->twig->render(
$template,
[
'results' => $results ?? null,
'searchForm' => $form->createView(),
'products' => $results ?? null,
'resources' => $results ?? null,
'search_form' => $form->createView(),
]
));
}
Expand Down
11 changes: 5 additions & 6 deletions src/Form/EventSubscriber/AddFacetsEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ private function modifyForm(FormInterface $form, AdapterInterface $adapter): voi
return;
}

$form->add(
'facets',
SearchFacetsType::class,
[
$form
->add('facets', SearchFacetsType::class, [
'facets' => $adapter->getAggregations(),
'label' => false,
]
);
'required' => false,
])
;
}
}
10 changes: 9 additions & 1 deletion src/Form/Type/SearchType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use BitBag\SyliusElasticsearchPlugin\Form\Resolver\ProductsFilterFacetResolverInterface;
use BitBag\SyliusElasticsearchPlugin\Model\Search;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -31,7 +32,14 @@ public function __construct(
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('box', SearchBoxType::class, ['label' => false])
->add('query', TextType::class, [
'label' => false,
'required' => false,
'attr' => [
'placeholder' => 'bitbag_sylius_elasticsearch_plugin.ui.search_box.query.placeholder',
'class' => 'prompt app-quick-add-code-input',
],
])
->setMethod('GET')
;

Expand Down
17 changes: 6 additions & 11 deletions src/Model/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,20 @@

namespace BitBag\SyliusElasticsearchPlugin\Model;

class Search
final class Search
{
private ?SearchBox $box;
private ?string $query = null;

private array $facets = [];

public function __construct()
public function getQuery(): ?string
{
$this->box = new SearchBox();
return $this->query;
}

public function getBox(): ?SearchBox
public function setQuery(?string $query): void
{
return $this->box;
}

public function setBox(?SearchBox $box): void
{
$this->box = $box;
$this->query = $query;
}

public function getFacets(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
min-width: 100%;
width: 600px;
padding: 0 1rem 0 1rem;
background-color: white;
Expand Down
Loading

0 comments on commit 7894209

Please sign in to comment.