Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGraml11 committed Nov 17, 2023
1 parent a19cf90 commit d725562
Show file tree
Hide file tree
Showing 24 changed files with 44 additions and 31 deletions.
6 changes: 5 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

Expand All @@ -16,7 +17,6 @@

$ecsConfig->rules([
DeclareStrictTypesFixer::class,
LineLengthFixer::class,
]);

$ecsConfig->skip([
Expand All @@ -38,6 +38,10 @@
'less_and_greater' => false,
]);

$ecsConfig->ruleWithConfiguration(LineLengthFixer::class, [
'inline_short_lines' => false,
]);

$ecsConfig->ruleWithConfiguration(TrailingCommaInMultilineFixer::class, [
'elements' => ['arguments', 'arrays', 'match', 'parameters'],
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Controller/NostoCategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function sync(Request $request, Context $context): JsonResponse
$criteria->getAssociation('seoUrls');
$criteria->addFilter(new EqualsFilter(
'active',
true
true,
));

$appToken = $this->configProvider->getAppToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function load(
/** @var CategoryEntity $category */
$category = $this->categoryRepository->search(
new Criteria([$categoryId]),
$context->getContext()
$context->getContext(),
)->first();

$streamId = $this->extendCriteria($context, $criteria, $category);
Expand Down Expand Up @@ -144,7 +144,7 @@ private function extendCriteria(
}

$criteria->addFilter(
new EqualsFilter('product.categoriesRo.id', $category->getId())
new EqualsFilter('product.categoriesRo.id', $category->getId()),
);

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Decorator/Storefront/Controller/CmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function filter(string $navigationId, Request $request, SalesChannelConte
}

return new JsonResponse(
$this->filterHandler->handleAvailableFilters($criteria)
$this->filterHandler->handleAvailableFilters($criteria),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Decorator/Storefront/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function filter(Request $request, SalesChannelContext $salesChannelContex
}

return new JsonResponse(
$this->filterHandler->handleAvailableFilters($criteria)
$this->filterHandler->handleAvailableFilters($criteria),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function build(array $bundles, array $themes): array
[
self::PLUGIN_TECH_NAME => 1,
],
$result
$result,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/CmsPageLoaderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
RequestStack $requestStack,
SessionLookupResolver $sessionLookupResolver,
NostoCacheResolver $cacheResolver,
LoggerInterface $logger
LoggerInterface $logger,
) {
$this->requestStack = $requestStack;
$this->sessionLookupResolver = $sessionLookupResolver;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function onKernelResponse(ResponseEvent $event): void
$this->logger->error(
sprintf(
'Unable to load resolve session, reason: %s',
$throwable->getMessage()
$throwable->getMessage(),
),
ContextHelper::createContextFromException($throwable),
);
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Nosto/Account/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\System\SalesChannel\SalesChannelEntity;
use Throwable;

class Provider
{
Expand Down Expand Up @@ -80,7 +81,7 @@ public function all(Context $context): array
new Token(Token::API_GRAPHQL, $this->configProvider->getAppToken($channelId, $languageId)),
]);
$this->accounts[] = new Account($channelId, $languageId, $accountName, $keyChain);
} catch (\Throwable $throwable) {
} catch (Throwable $throwable) {
$this->logger->error(
$throwable->getMessage(),
ContextHelper::createContextFromException($throwable),
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Nosto/Entity/Helper/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function loadExistingParentProducts(

public function loadProducts(
array $productIds,
SalesChannelContext $context
SalesChannelContext $context,
): ProductCollection {
$criteria = new Criteria();
$criteria->addFilter(new EqualsAnyFilter('id', $productIds));
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Nosto/Entity/Order/Status/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function build(OrderEntity $order): ?NostoOrderStatus
$orderNumber,
$orderStatus,
$paymentProvider,
$updatedAt
$updatedAt,
);

return $nostoOrderStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function build(string $productId, SalesChannelContext $context): array
$result = [];
foreach ($crossSellings as $crossSelling) {
$result[$this->createKeyFromName($crossSelling->getName())] = [
'productIds' => $this->useProductStream($crossSelling) ? $this->loadByStream($crossSelling, $context, new Criteria()) : $this->loadByIds($crossSelling, $context, new Criteria()),
'productIds' => $this->useProductStream($crossSelling)
? $this->loadByStream($crossSelling, $context, new Criteria())
: $this->loadByIds($crossSelling, $context, new Criteria()),
'position' => $crossSelling->getPosition(),
'sortBy' => $crossSelling->getSortBy(),
'sortDirection' => $crossSelling->getSortDirection(),
Expand Down Expand Up @@ -112,7 +114,7 @@ protected function loadByStream(

$filters = $this->productStreamBuilder->buildFilters(
$productStreamId,
$context->getContext()
$context->getContext(),
);

$criteria->addFilter(...$filters)
Expand Down
6 changes: 5 additions & 1 deletion src/Model/Operation/EntityChangelogSyncHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public function execute(object $message): JobResult
private function processMarketingPermissionEvents(Context $context, JobResult $result, string $parentJobId)
{
$type = EventsWriter::NEWSLETTER_ENTITY_NAME;
$this->processEventBatches($context, $type, function (array $subscriberIds) use ($parentJobId, $result, $context) {
$this->processEventBatches($context, $type, function (array $subscriberIds) use (
$parentJobId,
$result,
$context
) {
$jobMessage = new MarketingPermissionSyncMessage(Uuid::randomHex(), $parentJobId, $subscriberIds, $context);
$this->jobScheduler->schedule($jobMessage);
$result->addMessage(new InfoMessage(
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Operation/MarketingPermissionSyncHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function doOperation(AccountInterface $account, Context $context, array
[
NewsletterSubscribeRoute::OPTION_DIRECT,
NewsletterSubscribeRoute::STATUS_OPT_IN,
]
],
);
try {
$this->eventDispatcher->dispatch(
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Operation/ProductSyncHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private function getCategoriesTreeCollection($allProductCategoryPaths, $context)

$criteria = new Criteria();
$criteria->addFilter(
new EqualsAnyFilter('id', $categoriesPaths)
new EqualsAnyFilter('id', $categoriesPaths),
);

return $this->categoryRepository->search($criteria, $context)->getEntities();
Expand Down
4 changes: 2 additions & 2 deletions src/Search/Api/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function fetchFilters(
$nostoService->disable();

$this->logger->error(
sprintf('Error while fetching all filters: %s', $e->getMessage())
sprintf('Error while fetching all filters: %s', $e->getMessage()),
);
}
}
Expand All @@ -131,7 +131,7 @@ protected function fetchSelectableFilters(
$nostoService->disable();

$this->logger->error(
sprintf('Error while fetching the available filters: %s', $e->getMessage())
sprintf('Error while fetching the available filters: %s', $e->getMessage()),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Search/Request/Handler/AbstractRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function fetchProducts(Request $request, Criteria $criteria, SalesChannel
$responseParser = new GraphQLResponseParser($response);
} catch (Throwable $e) {
$this->logger->error(
sprintf('Error while fetching the products: %s', $e->getMessage())
sprintf('Error while fetching the products: %s', $e->getMessage()),
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Search/Request/Handler/SearchRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function handleRedirect(SalesChannelContext $context, Redirect $redire
{
$context->getContext()->addExtension(
'nostoRedirect',
$redirectExtension
$redirectExtension,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public function supportsSorting(FieldSorting $fieldSorting): bool;

public function generateSorting(
FieldSorting $fieldSorting,
SearchRequest $searchNavigationRequest
SearchRequest $searchNavigationRequest,
): void;
}
2 changes: 1 addition & 1 deletion src/Search/Request/SearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function addRangeFilter(string $filterField, ?string $min = null, ?string
if (array_key_exists($filterField, $this->filters)) {
$this->filters[$filterField]['range'] = array_merge(
$this->filters[$filterField]['range'],
$range
$range,
);
} else {
$this->filters[$filterField] = [
Expand Down
6 changes: 3 additions & 3 deletions src/Service/CategoryMerchandising/MerchandisingSearchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC
$this->logger->error(
sprintf(
'Unable to load resolve session, reason: %s',
$throwable->getMessage()
$throwable->getMessage(),
),
ContextHelper::createContextFromException($throwable)
ContextHelper::createContextFromException($throwable),
);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC
} catch (Exception $e) {
$this->logger->error(
$e->getMessage(),
ContextHelper::createContextFromException($e)
ContextHelper::createContextFromException($e),
);

return $this->repository->searchIds($criteria, $salesChannelContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PriceFilterTranslator implements TranslatorInterface

public function translate(
IncludeFilters $includeFilters,
RangeFilter $filters = null
RangeFilter $filters = null,
): IncludeFilters {
if ($filters) {
$includeFilters->setPrice($filters->getParameter("gte"), $filters->getParameter("lte"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function run(): void
$this->logger->error(
sprintf(
'Unable to sync job, the reason is: %s',
$e->getMessage()
$e->getMessage(),
),
ContextHelper::createContextFromException($e)
ContextHelper::createContextFromException($e),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Throwable;

class RestorerService implements RestorerServiceInterface
{
Expand Down
5 changes: 3 additions & 2 deletions src/Twig/Extension/NostoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Throwable;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

Expand Down Expand Up @@ -50,10 +51,10 @@ public function getNostoProduct(?SalesChannelProductEntity $product, SalesChanne
{
try {
return $product === null ? null : $this->productProvider->get($product, $context);
} catch (\Throwable $throwable) {
} catch (Throwable $throwable) {
$this->logger->error(
$throwable->getMessage(),
ContextHelper::createContextFromException($throwable)
ContextHelper::createContextFromException($throwable),
);
return null;
}
Expand Down

0 comments on commit d725562

Please sign in to comment.