diff --git a/ecs.php b/ecs.php index 9477f289..96e06c0e 100644 --- a/ecs.php +++ b/ecs.php @@ -2,9 +2,11 @@ declare(strict_types=1); +use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer; 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; @@ -18,7 +20,7 @@ ]); $ecsConfig->skip([ - NotOperatorWithSuccessorSpaceFixer::class + NotOperatorWithSuccessorSpaceFixer::class, ]); $ecsConfig->sets([ @@ -35,4 +37,12 @@ 'identical' => false, 'less_and_greater' => false, ]); + + $ecsConfig->ruleWithConfiguration(LineLengthFixer::class, [ + 'inline_short_lines' => false, + ]); + + $ecsConfig->ruleWithConfiguration(TrailingCommaInMultilineFixer::class, [ + 'elements' => ['arguments', 'arrays', 'match', 'parameters'], + ]); }; diff --git a/src/Api/Controller/NostoCategoriesController.php b/src/Api/Controller/NostoCategoriesController.php index 2b6846e8..7bba57d0 100644 --- a/src/Api/Controller/NostoCategoriesController.php +++ b/src/Api/Controller/NostoCategoriesController.php @@ -18,7 +18,7 @@ #[Route( defaults: [ '_routeScope' => ['api'], - ] + ], )] class NostoCategoriesController extends AbstractController { @@ -45,7 +45,7 @@ public function __construct( defaults: [ 'auth_required' => true, ], - methods: ["POST"] + methods: ["POST"], )] public function sync(Request $request, Context $context): JsonResponse { @@ -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( diff --git a/src/Api/Controller/NostoConfigController.php b/src/Api/Controller/NostoConfigController.php index 60894ffc..811614de 100644 --- a/src/Api/Controller/NostoConfigController.php +++ b/src/Api/Controller/NostoConfigController.php @@ -16,13 +16,13 @@ #[Route( defaults: [ '_routeScope' => ['api'], - ] + ], )] class NostoConfigController extends AbstractController { public function __construct( private readonly NostoConfigService $nostoConfigService, - private readonly Connection $connection + private readonly Connection $connection, ) { } diff --git a/src/Api/Controller/NostoController.php b/src/Api/Controller/NostoController.php index a64f7838..4ea7e362 100644 --- a/src/Api/Controller/NostoController.php +++ b/src/Api/Controller/NostoController.php @@ -25,7 +25,7 @@ #[Route( defaults: [ '_routeScope' => ['api'], - ] + ], )] class NostoController extends AbstractController { @@ -54,7 +54,7 @@ public function __construct(NostoSyncRoute $nostoSyncRoute, TagAwareAdapterInter #[Route( path: "/api/_action/nosto-integration/schedule-full-product-sync", name: "api.action.nosto_integration.schedule.full.product.sync", - methods: ["POST"] + methods: ["POST"], )] public function fullCatalogSyncAction(Request $request, Context $context): JsonResponse { @@ -64,7 +64,7 @@ public function fullCatalogSyncAction(Request $request, Context $context): JsonR #[Route( path: "/api/_action/nosto-integration/clear-cache", name: "api.action.nosto_integration.clear.cache", - methods: ["POST"] + methods: ["POST"], )] public function clearCache(): JsonResponse { @@ -78,7 +78,7 @@ public function clearCache(): JsonResponse options: [ "auth_required" => "false", ], - methods: ["POST"] + methods: ["POST"], )] public function validate(RequestDataBag $post): JsonResponse { diff --git a/src/Api/Route/NostoSyncRoute.php b/src/Api/Route/NostoSyncRoute.php index 5e7bca31..8f530f72 100644 --- a/src/Api/Route/NostoSyncRoute.php +++ b/src/Api/Route/NostoSyncRoute.php @@ -4,6 +4,7 @@ namespace Nosto\NostoIntegration\Api\Route; +use Exception; use Nosto\NostoIntegration\Async\FullCatalogSyncMessage; use Nosto\Scheduler\Entity\Job\JobEntity; use Nosto\Scheduler\Model\JobScheduler; @@ -21,7 +22,7 @@ #[Route( defaults: [ '_routeScope' => ['api'], - ] + ], )] class NostoSyncRoute { @@ -31,7 +32,7 @@ class NostoSyncRoute public function __construct( JobScheduler $jobScheduler, - EntityRepository $jobRepository + EntityRepository $jobRepository, ) { $this->jobScheduler = $jobScheduler; $this->jobRepository = $jobRepository; @@ -40,7 +41,7 @@ public function __construct( #[Route( path: "/api/schedule-full-product-sync", name: "api.nosto_integration_sync.full_sync", - methods: ["POST"] + methods: ["POST"], )] public function fullCatalogSync(Request $request, Context $context): JsonApiResponse { @@ -57,7 +58,7 @@ private function checkJobStatus(Context $context, string $type): void new AndFilter([ new EqualsFilter('type', $type), new EqualsAnyFilter('status', [JobEntity::TYPE_PENDING, JobEntity::TYPE_RUNNING]), - ]) + ]), ); /** @var JobEntity $job */ if ($job = $this->jobRepository->search($criteria, $context)->first()) { @@ -65,7 +66,7 @@ private function checkJobStatus(Context $context, string $type): void ? 'Job is already scheduled.' : 'Job is already running.'; - throw new \Exception($message); + throw new Exception($message); } } } diff --git a/src/Async/AbstractMessage.php b/src/Async/AbstractMessage.php index de51e1e7..9f3b46c7 100644 --- a/src/Async/AbstractMessage.php +++ b/src/Async/AbstractMessage.php @@ -22,14 +22,14 @@ abstract class AbstractMessage implements JobMessageInterface public function __construct( string $jobId, ?Context $context = null, - ?string $name = null + ?string $name = null, ) { $this->jobId = $jobId; $this->name = $name ?? static::$defaultName; $this->setContext($context); } - protected function setContext(?Context $context) + protected function setContext(?Context $context): void { // All values should be sent to nosto with the default currency and language if ($context === null) { @@ -48,7 +48,7 @@ protected function setContext(?Context $context) $context->getCurrencyFactor(), $context->considerInheritance(), $context->getTaxState(), - $context->getRounding() + $context->getRounding(), ); } else { $this->context = $context; diff --git a/src/Async/EventsWriter.php b/src/Async/EventsWriter.php index a0887459..1f02c397 100644 --- a/src/Async/EventsWriter.php +++ b/src/Async/EventsWriter.php @@ -24,7 +24,7 @@ public function __construct(EntityRepository $changelogRepository) $this->changelogRepository = $changelogRepository; } - public function writeEvent(string $name, string $id, Context $context, ?string $productNumber = null) + public function writeEvent(string $name, string $id, Context $context, ?string $productNumber = null): void { $this->changelogRepository->create([[ 'entityType' => $name, diff --git a/src/Async/MarketingPermissionSyncMessage.php b/src/Async/MarketingPermissionSyncMessage.php index 8d12ed6a..152065e0 100644 --- a/src/Async/MarketingPermissionSyncMessage.php +++ b/src/Async/MarketingPermissionSyncMessage.php @@ -21,7 +21,7 @@ public function __construct( string $parentJobId, array $newsletterRecipientIds, ?Context $context = null, - ?string $name = null + ?string $name = null, ) { parent::__construct($jobId, $context, $name); $this->newsletterRecipientIds = $newsletterRecipientIds; diff --git a/src/Async/OrderSyncMessage.php b/src/Async/OrderSyncMessage.php index 0ef50255..509f6be8 100644 --- a/src/Async/OrderSyncMessage.php +++ b/src/Async/OrderSyncMessage.php @@ -24,7 +24,7 @@ public function __construct( array $newOrderIds, array $updatedOrderIds, ?Context $context, - ?string $name = null + ?string $name = null, ) { parent::__construct($jobId, $context, $name); $this->newOrderIds = $newOrderIds; diff --git a/src/Async/ProductSyncMessage.php b/src/Async/ProductSyncMessage.php index 3e57c408..378e5bed 100644 --- a/src/Async/ProductSyncMessage.php +++ b/src/Async/ProductSyncMessage.php @@ -21,7 +21,7 @@ public function __construct( string $parentJobId, array $productIds, ?Context $context = null, - ?string $name = null + ?string $name = null, ) { parent::__construct($jobId, $context, $name); $this->productIds = $productIds; diff --git a/src/Controller/Storefront/CartController.php b/src/Controller/Storefront/CartController.php index 30291992..83d7cc88 100644 --- a/src/Controller/Storefront/CartController.php +++ b/src/Controller/Storefront/CartController.php @@ -13,7 +13,7 @@ #[Route( defaults: [ '_routeScope' => ['storefront'], - ] + ], )] class CartController extends StorefrontController { @@ -30,7 +30,7 @@ public function __construct(RestorerServiceInterface $restorerService) options: [ "seo" => "false", ], - methods: ["GET"] + methods: ["GET"], )] public function index(string $mappingId, SalesChannelContext $context): Response { diff --git a/src/Core/Content/Product/SalesChannel/Listing/Processor/NostoListingProcessor.php b/src/Core/Content/Product/SalesChannel/Listing/Processor/NostoListingProcessor.php index 80351a4f..bed27e43 100644 --- a/src/Core/Content/Product/SalesChannel/Listing/Processor/NostoListingProcessor.php +++ b/src/Core/Content/Product/SalesChannel/Listing/Processor/NostoListingProcessor.php @@ -31,7 +31,7 @@ public function prepare(Request $request, Criteria $criteria, SalesChannelContex if (SearchHelper::shouldHandleRequest( $context, $this->configProvider, - SearchHelper::isNavigationPage($request) + SearchHelper::isNavigationPage($request), )) { if (SearchHelper::isSearchPage($request)) { $this->searchService->doSearch($request, $criteria, $context); diff --git a/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php b/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php index 67ae87e8..8076ca98 100644 --- a/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php +++ b/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php @@ -47,7 +47,7 @@ public function load( string $categoryId, Request $request, SalesChannelContext $context, - Criteria $criteria = null + Criteria $criteria = null, ): ProductListingRouteResponse { $shouldHandleRequest = SearchHelper::shouldHandleRequest($context, $this->configProvider, true); @@ -61,14 +61,14 @@ public function load( $criteria->addFilter( new ProductAvailableFilter( $context->getSalesChannel()->getId(), - ProductVisibilityDefinition::VISIBILITY_ALL - ) + ProductVisibilityDefinition::VISIBILITY_ALL, + ), ); /** @var CategoryEntity $category */ $category = $this->categoryRepository->search( new Criteria([$categoryId]), - $context->getContext() + $context->getContext(), )->first(); $streamId = $this->extendCriteria($context, $criteria, $category); @@ -125,17 +125,17 @@ private function isRequestFromHomePage(Request $request): bool private function extendCriteria( SalesChannelContext $salesChannelContext, Criteria $criteria, - CategoryEntity $category + CategoryEntity $category, ): ?string { $supportsProductStreams = defined( - '\Shopware\Core\Content\Category\CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM' + '\Shopware\Core\Content\Category\CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM', ); $isProductStream = $supportsProductStreams && $category->getProductAssignmentType() === CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM; if ($isProductStream && $category->getProductStreamId() !== null) { $filters = $this->productStreamBuilder->buildFilters( $category->getProductStreamId(), - $salesChannelContext->getContext() + $salesChannelContext->getContext(), ); $criteria->addFilter(...$filters); @@ -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; @@ -152,7 +152,7 @@ private function extendCriteria( private function fetchProductsById( Criteria $criteria, - SalesChannelContext $salesChannelContext + SalesChannelContext $salesChannelContext, ): EntitySearchResult { if (empty($criteria->getIds())) { return $this->createEmptySearchResult($criteria, $salesChannelContext->getContext()); diff --git a/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php b/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php index 603ec744..04a580fc 100644 --- a/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php +++ b/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php @@ -34,7 +34,7 @@ public function __construct( private readonly ProductSearchBuilderInterface $searchBuilder, private readonly SalesChannelRepository $salesChannelProductRepository, private readonly CompositeListingProcessor $listingProcessor, - private readonly ConfigProvider $configProvider + private readonly ConfigProvider $configProvider, ) { } @@ -46,7 +46,7 @@ public function getDecorated(): AbstractProductSearchRoute public function load( Request $request, SalesChannelContext $context, - Criteria $criteria + Criteria $criteria, ): ProductSearchRouteResponse { if (!SearchHelper::shouldHandleRequest($context, $this->configProvider)) { return $this->decorated->load($request, $context, $criteria); @@ -65,8 +65,8 @@ public function load( $criteria->addFilter( new ProductAvailableFilter( $context->getSalesChannel()->getId(), - ProductVisibilityDefinition::VISIBILITY_SEARCH - ) + ProductVisibilityDefinition::VISIBILITY_SEARCH, + ), ); $this->searchBuilder->build($request, $criteria, $context); @@ -86,7 +86,7 @@ public function load( private function fetchProductsById( Criteria $criteria, SalesChannelContext $salesChannelContext, - ?string $query + ?string $query, ): EntitySearchResult { if (empty($criteria->getIds())) { return $this->createEmptySearchResult($criteria, $salesChannelContext->getContext()); diff --git a/src/Decorator/Core/Framework/DataAbstractionLayer/ProductRepositoryDecorator.php b/src/Decorator/Core/Framework/DataAbstractionLayer/ProductRepositoryDecorator.php index f1dc0bd2..4bddaa0d 100644 --- a/src/Decorator/Core/Framework/DataAbstractionLayer/ProductRepositoryDecorator.php +++ b/src/Decorator/Core/Framework/DataAbstractionLayer/ProductRepositoryDecorator.php @@ -39,7 +39,7 @@ public function __construct( EventDispatcherInterface $eventDispatcher, EntityLoadedEventFactory $eventFactory, EntityRepository $inner, - EventsWriter $eventsWriter + EventsWriter $eventsWriter, ) { parent::__construct($definition, $reader, $versionManager, $searcher, $aggregator, $eventDispatcher, $eventFactory); $this->inner = $inner; @@ -61,8 +61,12 @@ public function searchIds(Criteria $criteria, Context $context): IdSearchResult return $this->inner->searchIds($criteria, $context); } - public function clone(string $id, Context $context, ?string $newId = null, ?CloneBehavior $behavior = null): EntityWrittenContainerEvent - { + public function clone( + string $id, + Context $context, + ?string $newId = null, + ?CloneBehavior $behavior = null, + ): EntityWrittenContainerEvent { return $this->inner->clone($id, $context, $newId, $behavior); } @@ -106,7 +110,12 @@ public function delete(array $ids, Context $context): EntityWrittenContainerEven if ($event instanceof EntityDeletedEvent && $event->getEntityName() === ProductDefinition::ENTITY_NAME) { foreach ($event->getIds() as $productId) { if (!empty($orderNumberMapping[$productId])) { - $this->eventsWriter->writeEvent($event->getEntityName(), $productId, $event->getContext(), $orderNumberMapping[$productId]); + $this->eventsWriter->writeEvent( + $event->getEntityName(), + $productId, + $event->getContext(), + $orderNumberMapping[$productId], + ); } } } diff --git a/src/Decorator/Storefront/Controller/CmsController.php b/src/Decorator/Storefront/Controller/CmsController.php index 68046ef2..7c1b5cae 100644 --- a/src/Decorator/Storefront/Controller/CmsController.php +++ b/src/Decorator/Storefront/Controller/CmsController.php @@ -20,7 +20,7 @@ #[Route( defaults: [ '_routeScope' => ['storefront'], - ] + ], )] class CmsController extends StorefrontController { @@ -40,7 +40,7 @@ public function __construct( 'XmlHttpRequest' => true, '_httpCache' => true, ], - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], )] public function page(?string $id, Request $request, SalesChannelContext $salesChannelContext): Response { @@ -54,10 +54,13 @@ public function page(?string $id, Request $request, SalesChannelContext $salesCh 'navigationId' => null, 'XmlHttpRequest' => true, ], - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], )] - public function category(?string $navigationId, Request $request, SalesChannelContext $salesChannelContext): Response - { + public function category( + ?string $navigationId, + Request $request, + SalesChannelContext $salesChannelContext, + ): Response { return $this->decorated->category($navigationId, $request, $salesChannelContext); } @@ -69,7 +72,7 @@ public function category(?string $navigationId, Request $request, SalesChannelCo '_routeScope' => ['storefront'], '_httpCache' => true, ], - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], )] public function filter(string $navigationId, Request $request, SalesChannelContext $salesChannelContext): Response { @@ -85,7 +88,7 @@ public function filter(string $navigationId, Request $request, SalesChannelConte } return new JsonResponse( - $this->filterHandler->handleAvailableFilters($criteria) + $this->filterHandler->handleAvailableFilters($criteria), ); } @@ -98,7 +101,7 @@ public function filter(string $navigationId, Request $request, SalesChannelConte '_routeScope' => ['storefront'], '_httpCache' => true, ], - methods: ['GET'] + methods: ['GET'], )] public function switchBuyBoxVariant(string $productId, Request $request, SalesChannelContext $context): Response { diff --git a/src/Decorator/Storefront/Controller/SearchController.php b/src/Decorator/Storefront/Controller/SearchController.php index 43265080..1800646b 100644 --- a/src/Decorator/Storefront/Controller/SearchController.php +++ b/src/Decorator/Storefront/Controller/SearchController.php @@ -28,7 +28,7 @@ #[Route( defaults: [ '_routeScope' => ['storefront'], - ] + ], )] class SearchController extends StorefrontController { @@ -38,7 +38,7 @@ public function __construct( private readonly ConfigProvider $configProvider, private readonly SearchService $searchService, private readonly SearchPageLoader $searchPageLoader, - ContainerInterface $container + ContainerInterface $container, ) { $this->container = $container; } @@ -49,7 +49,7 @@ public function __construct( defaults: [ '_httpCache' => true, ], - methods: ['GET'] + methods: ['GET'], )] public function search(SalesChannelContext $context, Request $request): Response { @@ -96,7 +96,7 @@ public function search(SalesChannelContext $context, Request $request): Response 'XmlHttpRequest' => true, '_httpCache' => true, ], - methods: ['GET'] + methods: ['GET'], )] public function suggest(SalesChannelContext $context, Request $request): Response { @@ -111,7 +111,7 @@ public function suggest(SalesChannelContext $context, Request $request): Respons '_routeScope' => ['storefront'], '_httpCache' => true, ], - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], )] public function ajax(Request $request, SalesChannelContext $context): Response { @@ -126,7 +126,7 @@ public function ajax(Request $request, SalesChannelContext $context): Response '_routeScope' => ['storefront'], '_httpCache' => true, ], - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], )] public function filter(Request $request, SalesChannelContext $salesChannelContext): Response { @@ -142,7 +142,7 @@ public function filter(Request $request, SalesChannelContext $salesChannelContex } return new JsonResponse( - $this->filterHandler->handleAvailableFilters($criteria) + $this->filterHandler->handleAvailableFilters($criteria), ); } } diff --git a/src/Decorator/Storefront/Framework/Cookie/NostoCookieProvider.php b/src/Decorator/Storefront/Framework/Cookie/NostoCookieProvider.php index 52529df2..bd14d140 100644 --- a/src/Decorator/Storefront/Framework/Cookie/NostoCookieProvider.php +++ b/src/Decorator/Storefront/Framework/Cookie/NostoCookieProvider.php @@ -20,7 +20,7 @@ public function getCookieGroups(): array $cookies = $this->originalService->getCookieGroups(); foreach ($cookies as &$cookie) { - if (!\is_array($cookie)) { + if (!is_array($cookie)) { continue; } @@ -28,7 +28,7 @@ public function getCookieGroups(): array continue; } - if (!\array_key_exists('entries', $cookie)) { + if (!array_key_exists('entries', $cookie)) { continue; } @@ -46,7 +46,7 @@ public function getCookieGroups(): array private function isRequiredCookieGroup(array $cookie): bool { - return (\array_key_exists('isRequired', $cookie) && $cookie['isRequired'] === true) - && (\array_key_exists('snippet_name', $cookie) && $cookie['snippet_name'] === 'cookie.groupRequired'); + return (array_key_exists('isRequired', $cookie) && $cookie['isRequired'] === true) + && (array_key_exists('snippet_name', $cookie) && $cookie['snippet_name'] === 'cookie.groupRequired'); } } diff --git a/src/Decorator/Storefront/Theme/Twig/ThemeInheritanceBuilderDecorator.php b/src/Decorator/Storefront/Theme/Twig/ThemeInheritanceBuilderDecorator.php index b6a97ae7..40a39dfb 100644 --- a/src/Decorator/Storefront/Theme/Twig/ThemeInheritanceBuilderDecorator.php +++ b/src/Decorator/Storefront/Theme/Twig/ThemeInheritanceBuilderDecorator.php @@ -23,11 +23,11 @@ public function build(array $bundles, array $themes): array if (isset($result[self::PLUGIN_TECH_NAME])) { unset($result[self::PLUGIN_TECH_NAME]); - $result = \array_merge( + $result = array_merge( [ self::PLUGIN_TECH_NAME => 1, ], - $result + $result, ); } diff --git a/src/EventListener/CmsPageLoaderListener.php b/src/EventListener/CmsPageLoaderListener.php index 895064ac..a83c6cf6 100644 --- a/src/EventListener/CmsPageLoaderListener.php +++ b/src/EventListener/CmsPageLoaderListener.php @@ -30,7 +30,7 @@ public function __construct( RequestStack $requestStack, SessionLookupResolver $sessionLookupResolver, NostoCacheResolver $cacheResolver, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->requestStack = $requestStack; $this->sessionLookupResolver = $sessionLookupResolver; @@ -73,9 +73,9 @@ public function onKernelResponse(ResponseEvent $event): void $this->logger->error( sprintf( 'Unable to load resolve session, reason: %s', - $throwable->getMessage() + $throwable->getMessage(), ), - ContextHelper::createContextFromException($throwable) + ContextHelper::createContextFromException($throwable), ); } diff --git a/src/EventListener/ListingPageEventListener.php b/src/EventListener/ListingPageEventListener.php index 353460f3..e80830ae 100644 --- a/src/EventListener/ListingPageEventListener.php +++ b/src/EventListener/ListingPageEventListener.php @@ -31,7 +31,7 @@ public function removeScoreSorting(ProductListingResultEvent $event): void { if ($this->configProvider->isMerchEnabled( $event->getSalesChannelContext()->getSalesChannelId(), - $event->getSalesChannelContext()->getLanguageId() + $event->getSalesChannelContext()->getLanguageId(), )) { return; } diff --git a/src/EventListener/NewsletterEventListener.php b/src/EventListener/NewsletterEventListener.php index 09c6355b..5b03334f 100644 --- a/src/EventListener/NewsletterEventListener.php +++ b/src/EventListener/NewsletterEventListener.php @@ -18,7 +18,7 @@ public function __construct(EventsWriter $eventsWriter) $this->eventsWriter = $eventsWriter; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ NewsletterConfirmEvent::class => 'onNewsletterConfirm', @@ -26,21 +26,21 @@ public static function getSubscribedEvents() ]; } - public function onNewsletterConfirm(NewsletterConfirmEvent $event) + public function onNewsletterConfirm(NewsletterConfirmEvent $event): void { $this->eventsWriter->writeEvent( $this->eventsWriter::NEWSLETTER_ENTITY_NAME, $event->getNewsletterRecipient()->getId(), - $event->getContext() + $event->getContext(), ); } - public function onNewsletterUnsubscribe(NewsletterUnsubscribeEvent $event) + public function onNewsletterUnsubscribe(NewsletterUnsubscribeEvent $event): void { $this->eventsWriter->writeEvent( $this->eventsWriter::NEWSLETTER_ENTITY_NAME, $event->getNewsletterRecipient()->getId(), - $event->getContext() + $event->getContext(), ); } } diff --git a/src/EventListener/OrderWrittenEventListener.php b/src/EventListener/OrderWrittenEventListener.php index b724f6d0..fa415fd7 100644 --- a/src/EventListener/OrderWrittenEventListener.php +++ b/src/EventListener/OrderWrittenEventListener.php @@ -18,7 +18,7 @@ public function __construct(EventsWriter $eventsWriter) $this->eventsWriter = $eventsWriter; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'state_machine.order.state_changed' => 'onOrderWritten', @@ -26,21 +26,21 @@ public static function getSubscribedEvents() ]; } - public function onCheckoutOrderPlaced(CheckoutOrderPlacedEvent $event) + public function onCheckoutOrderPlaced(CheckoutOrderPlacedEvent $event): void { $this->eventsWriter->writeEvent( $this->eventsWriter::ORDER_ENTITY_PLACED_NAME, $event->getOrder()->getId(), - $event->getContext() + $event->getContext(), ); } - public function onOrderWritten(StateMachineStateChangeEvent $event) + public function onOrderWritten(StateMachineStateChangeEvent $event): void { $this->eventsWriter->writeEvent( $this->eventsWriter::ORDER_ENTITY_UPDATED_NAME, $event->getTransition()->getEntityId(), - $event->getContext() + $event->getContext(), ); } } diff --git a/src/EventListener/ProductWrittenDeletedEvent.php b/src/EventListener/ProductWrittenDeletedEvent.php index b3f00226..f5d571b3 100644 --- a/src/EventListener/ProductWrittenDeletedEvent.php +++ b/src/EventListener/ProductWrittenDeletedEvent.php @@ -22,14 +22,14 @@ public function __construct(EventsWriter $eventsWriter, ProductHelper $productHe $this->productHelper = $productHelper; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ProductEvents::PRODUCT_WRITTEN_EVENT => 'onProductWritten', ]; } - public function onProductWritten(EntityWrittenEvent $event) + public function onProductWritten(EntityWrittenEvent $event): void { $orderNumberMapping = $this->productHelper->loadOrderNumberMapping($event->getIds(), $event->getContext()); @@ -39,7 +39,7 @@ public function onProductWritten(EntityWrittenEvent $event) $event->getEntityName(), $productId, $event->getContext(), - $orderNumberMapping[$productId] + $orderNumberMapping[$productId], ); } } diff --git a/src/Migration/Migration1680010097.php b/src/Migration/Migration1680010097.php index 9889bd13..6f7604e2 100644 --- a/src/Migration/Migration1680010097.php +++ b/src/Migration/Migration1680010097.php @@ -31,7 +31,11 @@ private function addColumn(Connection $connection): void private function hasColumn(string $table, string $columnName, Connection $connection): bool { - return \in_array($columnName, array_column($connection->fetchAllAssociative(\sprintf('SHOW COLUMNS FROM `%s`', $table)), 'Field'), true); + return in_array( + $columnName, + array_column($connection->fetchAllAssociative(sprintf('SHOW COLUMNS FROM `%s`', $table)), 'Field'), + true, + ); } public function updateDestructive(Connection $connection): void diff --git a/src/Migration/Migration1699534500ConfigTable.php b/src/Migration/Migration1699534500ConfigTable.php index bcbf88f0..bf38fa06 100644 --- a/src/Migration/Migration1699534500ConfigTable.php +++ b/src/Migration/Migration1699534500ConfigTable.php @@ -92,7 +92,7 @@ private function insertPreviousConfigurationIfExists(Connection $connection): vo try { $connection->insert('nosto_integration_config', $data); - } catch (Exception $exception) { + } catch (Exception) { // Do nothing here as configuration already exists } } diff --git a/src/Model/Config/NostoConfigService.php b/src/Model/Config/NostoConfigService.php index 4c4164da..8284cb5c 100644 --- a/src/Model/Config/NostoConfigService.php +++ b/src/Model/Config/NostoConfigService.php @@ -88,7 +88,7 @@ class NostoConfigService private array $configs = []; public function __construct( - private readonly EntityRepository $nostoConfigRepository + private readonly EntityRepository $nostoConfigRepository, ) { } @@ -188,7 +188,7 @@ public function set(string $key, mixed $value, ?string $salesChannelId = null, ? 'languageId' => $languageId, ], ], - Context::createDefaultContext() + Context::createDefaultContext(), ); } @@ -222,7 +222,7 @@ private function getId(string $key, ?string $salesChannelId = null, ?string $lan private function buildCriteria( ?string $salesChannelId = null, ?string $languageId = null, - ?string $key = null + ?string $key = null, ): Criteria { $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('salesChannelId', $salesChannelId)); @@ -260,8 +260,8 @@ private function loadConfigsFromDatabase(?string $salesChannelId = null, ?string $criteria->addFilter( new MultiFilter( MultiFilter::CONNECTION_AND, - [new EqualsFilter('salesChannelId', $salesChannelId), new EqualsFilter('languageId', $languageId)] - ) + [new EqualsFilter('salesChannelId', $salesChannelId), new EqualsFilter('languageId', $languageId)], + ), ); $criteria->addSorting(new FieldSorting('id', FieldSorting::ASCENDING)); diff --git a/src/Model/Config/NostoSalesChannelExtension.php b/src/Model/Config/NostoSalesChannelExtension.php index 94fcedd8..37bed29e 100644 --- a/src/Model/Config/NostoSalesChannelExtension.php +++ b/src/Model/Config/NostoSalesChannelExtension.php @@ -14,7 +14,7 @@ class NostoSalesChannelExtension extends EntityExtension public function extendFields(FieldCollection $collection): void { $collection->add( - new OneToManyAssociationField('salesChannel', NostoConfigDefinition::class, 'sales_channel_id') + new OneToManyAssociationField('salesChannel', NostoConfigDefinition::class, 'sales_channel_id'), ); } diff --git a/src/Model/ConfigProvider.php b/src/Model/ConfigProvider.php index ff20bcdf..d43b5a9b 100644 --- a/src/Model/ConfigProvider.php +++ b/src/Model/ConfigProvider.php @@ -9,7 +9,7 @@ class ConfigProvider { public function __construct( - private readonly NostoConfigService $configService + private readonly NostoConfigService $configService, ) { } @@ -63,7 +63,7 @@ public function shouldInitializeNostoAfterInteraction($channelId = null, $langua return $this->configService->getBool( NostoConfigService::INITIALIZE_NOSTO_AFTER_INTERACTION, $channelId, - $languageId + $languageId, ); } @@ -94,7 +94,7 @@ public function getTagFieldKey(int $tagNumber, $channelId = null, $languageId = $config = $this->configService->get( NostoConfigService::TAG_FIELD_TEMPLATE . $tagNumber, $channelId, - $languageId + $languageId, ); if (is_string($config) && !empty($config)) { return [$config]; @@ -162,7 +162,7 @@ public function isEnabledCustomerDataToNosto($channelId = null, $languageId = nu return $this->configService->getBool( NostoConfigService::ENABLE_CUSTOMER_DATA_TO_NOSTO, $channelId, - $languageId + $languageId, ); } @@ -171,7 +171,7 @@ public function isEnabledSyncInactiveProducts($channelId = null, $languageId = n return $this->configService->getBool( NostoConfigService::ENABLE_SYNC_INACTIVE_PRODUCTS, $channelId, - $languageId + $languageId, ); } @@ -180,7 +180,7 @@ public function isEnabledProductPublishedDateTagging($channelId = null, $languag return $this->configService->getBool( NostoConfigService::ENABLE_PRODUCT_PUBLISHED_DATE_TAGGING, $channelId, - $languageId + $languageId, ); } @@ -189,7 +189,7 @@ public function isEnabledReloadRecommendationsAfterAdding($channelId = null, $la return $this->configService->getBool( NostoConfigService::ENABLE_RELOAD_RECOMMENDATIONS_AFTER_ADDING, $channelId, - $languageId + $languageId, ); } @@ -198,7 +198,7 @@ public function isEnabledProductLabellingSync($channelId = null, $languageId = n return $this->configService->getBool( NostoConfigService::ENABLE_PRODUCT_LABELLING_SYNC, $channelId, - $languageId + $languageId, ); } diff --git a/src/Model/MockOperation/MockGraphQLOperation.php b/src/Model/MockOperation/MockGraphQLOperation.php index 418cd10f..dac1fe01 100644 --- a/src/Model/MockOperation/MockGraphQLOperation.php +++ b/src/Model/MockOperation/MockGraphQLOperation.php @@ -9,17 +9,17 @@ class MockGraphQLOperation extends AbstractGraphQLOperation { - public function getQuery() + public function getQuery(): string { return ''; } - public function getVariables() + public function getVariables(): array { return []; } - protected function getResultHandler() + protected function getResultHandler(): MockResultHandler { return new MockResultHandler(); } diff --git a/src/Model/MockOperation/MockMarketingPermission.php b/src/Model/MockOperation/MockMarketingPermission.php index 910ba538..060a3a10 100644 --- a/src/Model/MockOperation/MockMarketingPermission.php +++ b/src/Model/MockOperation/MockMarketingPermission.php @@ -7,15 +7,16 @@ use Nosto\NostoIntegration\Model\MockOperation\Result\MockResultHandler; use Nosto\Operation\MarketingPermission; use Nosto\Request\Api\Token; +use Nosto\Result\Graphql\Recommendation\ResultSet; class MockMarketingPermission extends MarketingPermission { - public function mockUpdate() + public function mockUpdate(): string|array|bool|ResultSet { $request = $this->initRequest( $this->account->getApiToken(Token::API_EMAIL), $this->account->getName(), - $this->activeDomain + $this->activeDomain, ); $request->setReplaceParams([]); $response = $request->postRaw(''); @@ -23,7 +24,7 @@ public function mockUpdate() return $request->getResultHandler()->parse($response); } - protected function getResultHandler() + protected function getResultHandler(): MockResultHandler { return new MockResultHandler(); } diff --git a/src/Model/MockOperation/MockSearchOperation.php b/src/Model/MockOperation/MockSearchOperation.php index 5d509fad..8123690c 100644 --- a/src/Model/MockOperation/MockSearchOperation.php +++ b/src/Model/MockOperation/MockSearchOperation.php @@ -12,12 +12,12 @@ class MockSearchOperation extends AbstractSearchOperation { public function __construct( private readonly string $accountId, - AccountInterface $account + AccountInterface $account, ) { parent::__construct($account); } - public function getQuery() + public function getQuery(): string { return << '', @@ -44,7 +44,7 @@ public function getVariables() ]; } - protected function getResultHandler() + protected function getResultHandler(): MockSearchResultHandler { return new MockSearchResultHandler(); } diff --git a/src/Model/MockOperation/MockUpsertProduct.php b/src/Model/MockOperation/MockUpsertProduct.php index 5012f6c8..b2cce3d3 100644 --- a/src/Model/MockOperation/MockUpsertProduct.php +++ b/src/Model/MockOperation/MockUpsertProduct.php @@ -8,22 +8,23 @@ use Nosto\NostoIntegration\Model\MockOperation\Result\MockResultHandler; use Nosto\Operation\UpsertProduct; use Nosto\Request\Api\Token; +use Nosto\Result\Graphql\Recommendation\ResultSet; class MockUpsertProduct extends UpsertProduct { - public function upsert() + public function upsert(): ResultSet|bool|array|string { $request = $this->initRequest( $this->account->getApiToken(Token::API_PRODUCTS), $this->account->getName(), - $this->activeDomain + $this->activeDomain, ); $response = $request->post(new ProductCollection()); return $this->getResultHandler()->parse($response); } - protected function getResultHandler() + protected function getResultHandler(): MockResultHandler { return new MockResultHandler(); } diff --git a/src/Model/MockOperation/Result/MockResultHandler.php b/src/Model/MockOperation/Result/MockResultHandler.php index 8d9f8c83..42af1e6d 100644 --- a/src/Model/MockOperation/Result/MockResultHandler.php +++ b/src/Model/MockOperation/Result/MockResultHandler.php @@ -5,16 +5,17 @@ namespace Nosto\NostoIntegration\Model\MockOperation\Result; use Nosto\Request\Http\HttpResponse; +use Nosto\Result\Graphql\Recommendation\ResultSet; use Nosto\Result\ResultHandler; class MockResultHandler extends ResultHandler { - public function parse(HttpResponse $response) + public function parse(HttpResponse $response): ResultSet|array|bool|string { return $this->parseResponse($response); } - protected function parseResponse(HttpResponse $response) + protected function parseResponse(HttpResponse $response): array { if ($response->getCode() > 400) { $result = json_decode($response->getResult(), true); diff --git a/src/Model/MockOperation/Result/MockSearchResultHandler.php b/src/Model/MockOperation/Result/MockSearchResultHandler.php index b5d0d853..8c06424a 100644 --- a/src/Model/MockOperation/Result/MockSearchResultHandler.php +++ b/src/Model/MockOperation/Result/MockSearchResultHandler.php @@ -5,16 +5,17 @@ namespace Nosto\NostoIntegration\Model\MockOperation\Result; use Nosto\Request\Http\HttpResponse; +use Nosto\Result\Graphql\Recommendation\ResultSet; use Nosto\Result\ResultHandler; class MockSearchResultHandler extends ResultHandler { - public function parse(HttpResponse $response) + public function parse(HttpResponse $response): ResultSet|bool|array|string { return $this->parseResponse($response); } - protected function parseResponse(HttpResponse $response) + protected function parseResponse(HttpResponse $response): array { if ($response->getCode() === 200) { $result = json_decode($response->getResult(), true); diff --git a/src/Model/Nosto/Account.php b/src/Model/Nosto/Account.php index a775c640..b158701e 100644 --- a/src/Model/Nosto/Account.php +++ b/src/Model/Nosto/Account.php @@ -5,6 +5,7 @@ namespace Nosto\NostoIntegration\Model\Nosto; use Nosto\Model\Signup\Account as NostoSignupAccount; +use Nosto\NostoIntegration\Model\Nosto\Account\KeyChain; class Account { @@ -14,7 +15,7 @@ class Account private string $accountName; - private Account\KeyChain $keyChain; + private KeyChain $keyChain; private ?NostoSignupAccount $nostoAccount = null; @@ -22,7 +23,7 @@ public function __construct( string $channelId, string $languageId, string $accountName, - Account\KeyChain $keyChain + KeyChain $keyChain, ) { $this->channelId = $channelId; $this->languageId = $languageId; @@ -40,7 +41,7 @@ public function getLanguageId(): string return $this->languageId; } - public function getKeyChain(): Account\KeyChain + public function getKeyChain(): KeyChain { return $this->keyChain; } diff --git a/src/Model/Nosto/Account/Provider.php b/src/Model/Nosto/Account/Provider.php index 8dbd7304..d2d21aa1 100644 --- a/src/Model/Nosto/Account/Provider.php +++ b/src/Model/Nosto/Account/Provider.php @@ -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 { @@ -28,7 +29,7 @@ class Provider public function __construct( ConfigProvider $configProvider, EntityRepository $channelRepo, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->configProvider = $configProvider; $this->channelRepo = $channelRepo; @@ -80,10 +81,10 @@ 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) + ContextHelper::createContextFromException($throwable), ); } } diff --git a/src/Model/Nosto/Entity/Customer/Builder.php b/src/Model/Nosto/Entity/Customer/Builder.php index 868b7f12..21005dc4 100644 --- a/src/Model/Nosto/Entity/Customer/Builder.php +++ b/src/Model/Nosto/Entity/Customer/Builder.php @@ -45,9 +45,10 @@ private function hasMarketingPermission(CustomerEntity $customer, Context $conte $criteria->addFilter(new EqualsFilter('email', $customer->getEmail())); $subscriber = $this->newsletterRecipientRepository->search($criteria, $context)->first(); - return $subscriber !== null - ? in_array($subscriber->getStatus(), [Newsletter::OPTION_DIRECT, Newsletter::STATUS_OPT_IN]) - : false; + return $subscriber !== null && in_array( + $subscriber->getStatus(), + [Newsletter::OPTION_DIRECT, Newsletter::STATUS_OPT_IN], + ); } public static function generateCustomerReference(CustomerEntity $customer): string diff --git a/src/Model/Nosto/Entity/Customer/Event/NostoCustomerBuiltEvent.php b/src/Model/Nosto/Entity/Customer/Event/NostoCustomerBuiltEvent.php index 5c8c977a..6fb1a822 100644 --- a/src/Model/Nosto/Entity/Customer/Event/NostoCustomerBuiltEvent.php +++ b/src/Model/Nosto/Entity/Customer/Event/NostoCustomerBuiltEvent.php @@ -20,7 +20,7 @@ class NostoCustomerBuiltEvent extends NestedEvent public function __construct( CustomerEntity $customer, NostoCustomer $nostoCustomer, - Context $context + Context $context, ) { $this->customer = $customer; $this->nostoCustomer = $nostoCustomer; diff --git a/src/Model/Nosto/Entity/Helper/ProductHelper.php b/src/Model/Nosto/Entity/Helper/ProductHelper.php index a63a0c64..f617d840 100644 --- a/src/Model/Nosto/Entity/Helper/ProductHelper.php +++ b/src/Model/Nosto/Entity/Helper/ProductHelper.php @@ -46,7 +46,7 @@ public function __construct( AbstractProductDetailRoute $productRoute, EntityRepository $reviewRepository, EventDispatcherInterface $eventDispatcher, - ConfigProvider $configProvider + ConfigProvider $configProvider, ) { $this->productRepository = $productRepository; $this->productRoute = $productRoute; @@ -63,7 +63,7 @@ public function getReviewsCount(SalesChannelProductEntity $product, SalesChannel new MultiFilter(MultiFilter::CONNECTION_OR, [ new EqualsFilter('product.id', $product->getId()), new EqualsFilter('product.parentId', $product->getId()), - ]) + ]), ); $reviewCriteria->addAggregation(new CountAggregation('review-count', 'id')); $aggregation = $this->reviewRepository->aggregate($reviewCriteria, $context->getContext())->get('review-count'); @@ -96,7 +96,7 @@ private function getCommonCriteria(): Criteria public function loadExistingParentProducts( array $existentParentProductIds, - SalesChannelContext $context + SalesChannelContext $context, ): EntitySearchResult { $criteria = $this->getCommonCriteria(); $criteria->addAssociation('children.manufacturer'); @@ -104,7 +104,7 @@ public function loadExistingParentProducts( if (!$this->configProvider->isEnabledSyncInactiveProducts( $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), )) { $criteria->addFilter(new EqualsFilter('active', true)); } @@ -116,13 +116,13 @@ public function loadExistingParentProducts( public function loadProducts( array $productIds, - SalesChannelContext $context + SalesChannelContext $context, ): ProductCollection { $criteria = new Criteria(); $criteria->addFilter(new EqualsAnyFilter('id', $productIds)); if (!$this->configProvider->isEnabledSyncInactiveProducts( $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), )) { $criteria->addFilter(new EqualsFilter('active', true)); } diff --git a/src/Model/Nosto/Entity/Order/Builder.php b/src/Model/Nosto/Entity/Order/Builder.php index 9c48fccf..bb9f4b15 100644 --- a/src/Model/Nosto/Entity/Order/Builder.php +++ b/src/Model/Nosto/Entity/Order/Builder.php @@ -29,7 +29,7 @@ class Builder implements BuilderInterface public function __construct( NostoBuyerBuilderInterface $buyerBuilder, NostoOrderItemBuilderInterface $nostoOrderItemBuilder, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $eventDispatcher, ) { $this->buyerBuilder = $buyerBuilder; $this->nostoOrderItemBuilder = $nostoOrderItemBuilder; @@ -70,8 +70,8 @@ public function build(OrderEntity $order, Context $context): NostoOrder $nostoItem = new NostoLineItem(); $nostoItem->loadSpecialItemData( 'Shipping and handling', - $shippingInclTax === null ? 0 : $shippingInclTax, - $order->getCurrency()->getIsoCode() + $shippingInclTax, + $order->getCurrency()->getIsoCode(), ); $nostoOrder->addPurchasedItems($nostoItem); } diff --git a/src/Model/Nosto/Entity/Order/Buyer/Builder.php b/src/Model/Nosto/Entity/Order/Buyer/Builder.php index d6ae5903..12aaa287 100644 --- a/src/Model/Nosto/Entity/Order/Buyer/Builder.php +++ b/src/Model/Nosto/Entity/Order/Buyer/Builder.php @@ -22,7 +22,7 @@ public function buildObject( $customerGroup = null, $dateOfBirth = null, $gender = null, - $customerReference = null + $customerReference = null, ): Buyer { $buyer = new Buyer(); $buyer->setFirstName($firstName); @@ -43,12 +43,12 @@ public function fromOrder(OrderEntity $order): ?AbstractPerson $countryId = null; if ($address instanceof OrderAddressEntity) { $telephone = $address->getPhoneNumber() ? (string) $address->getPhoneNumber() : null; - $postcode = $address->getZipcode() ? (string) $address->getZipcode() : null; - $countryId = $address->getCountryId() ? (string) $address->getCountryId() : null; + $postcode = $address->getZipcode() ?: null; + $countryId = $address->getCountryId() ?: null; } - $customerFirstname = $order->getOrderCustomer()->getFirstName() ? (string) $order->getOrderCustomer()->getFirstName() : ''; - $customerLastname = $order->getOrderCustomer()->getLastName() ? (string) $order->getOrderCustomer()->getLastName() : ''; - $customerEmail = $order->getOrderCustomer()->getEmail() ? (string) $order->getOrderCustomer()->getEmail() : ''; + $customerFirstname = $order->getOrderCustomer()->getFirstName() ?: ''; + $customerLastname = $order->getOrderCustomer()->getLastName() ?: ''; + $customerEmail = $order->getOrderCustomer()->getEmail() ?: ''; return $this->build( $customerFirstname, @@ -56,7 +56,7 @@ public function fromOrder(OrderEntity $order): ?AbstractPerson $customerEmail, $telephone, $postcode, - $countryId + $countryId, ); } } diff --git a/src/Model/Nosto/Entity/Order/Event/NostoOrderBuiltEvent.php b/src/Model/Nosto/Entity/Order/Event/NostoOrderBuiltEvent.php index a91e6a55..4cf149aa 100644 --- a/src/Model/Nosto/Entity/Order/Event/NostoOrderBuiltEvent.php +++ b/src/Model/Nosto/Entity/Order/Event/NostoOrderBuiltEvent.php @@ -20,7 +20,7 @@ class NostoOrderBuiltEvent extends NestedEvent public function __construct( OrderEntity $order, NostoOrder $nostoOrder, - Context $context + Context $context, ) { $this->order = $order; $this->nostoOrder = $nostoOrder; diff --git a/src/Model/Nosto/Entity/Order/Event/NostoOrderCriteriaEvent.php b/src/Model/Nosto/Entity/Order/Event/NostoOrderCriteriaEvent.php index a80dc1e2..62897d41 100644 --- a/src/Model/Nosto/Entity/Order/Event/NostoOrderCriteriaEvent.php +++ b/src/Model/Nosto/Entity/Order/Event/NostoOrderCriteriaEvent.php @@ -16,7 +16,7 @@ class NostoOrderCriteriaEvent extends NestedEvent public function __construct( Criteria $criteria, - Context $context + Context $context, ) { $this->criteria = $criteria; $this->context = $context; diff --git a/src/Model/Nosto/Entity/Order/Item/Builder.php b/src/Model/Nosto/Entity/Order/Item/Builder.php index 81439176..42d5d233 100644 --- a/src/Model/Nosto/Entity/Order/Item/Builder.php +++ b/src/Model/Nosto/Entity/Order/Item/Builder.php @@ -4,6 +4,7 @@ namespace Nosto\NostoIntegration\Model\Nosto\Entity\Order\Item; +use Exception; use Nosto\Model\Cart\LineItem as NostoLineItem; use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity; use Shopware\Core\System\Currency\CurrencyEntity; @@ -21,7 +22,7 @@ public function build(OrderLineItemEntity $item, CurrencyEntity $currency): Nost try { $price = $item->getTotalPrice(); $nostoItem->setPrice($price); - } catch (\Exception $e) { + } catch (Exception) { $nostoItem->setPrice(0); } diff --git a/src/Model/Nosto/Entity/Order/Status/Builder.php b/src/Model/Nosto/Entity/Order/Status/Builder.php index d225b04d..827ac02d 100644 --- a/src/Model/Nosto/Entity/Order/Status/Builder.php +++ b/src/Model/Nosto/Entity/Order/Status/Builder.php @@ -23,14 +23,13 @@ public function build(OrderEntity $order): ?NostoOrderStatus } else { throw new NostoException('Order has no payment associated'); } - $nostoOrderStatus = new NostoOrderStatus( + + return new NostoOrderStatus( $orderNumber, $orderStatus, $paymentProvider, - $updatedAt + $updatedAt, ); - - return $nostoOrderStatus; } catch (Exception $e) { throw new Exception('Unable to build product, reason: ' . $e->getMessage()); } diff --git a/src/Model/Nosto/Entity/Person/Builder.php b/src/Model/Nosto/Entity/Person/Builder.php index b18dd96c..dcc43d0d 100644 --- a/src/Model/Nosto/Entity/Person/Builder.php +++ b/src/Model/Nosto/Entity/Person/Builder.php @@ -18,9 +18,9 @@ public function build( $customerGroup = null, $dateOfBirth = null, $gender = null, - $customerReference = null + $customerReference = null, ): ?AbstractPerson { - $person = $this->buildObject( + return $this->buildObject( $firstName, $lastName, $email, @@ -30,10 +30,8 @@ public function build( $customerGroup, $dateOfBirth, $gender, - $customerReference + $customerReference, ); - - return $person; } abstract public function buildObject( @@ -46,6 +44,6 @@ abstract public function buildObject( $customerGroup = null, $dateOfBirth = null, $gender = null, - $customerReference = null + $customerReference = null, ): AbstractPerson; } diff --git a/src/Model/Nosto/Entity/Person/BuilderInterface.php b/src/Model/Nosto/Entity/Person/BuilderInterface.php index 1d993ae7..d108bb2b 100644 --- a/src/Model/Nosto/Entity/Person/BuilderInterface.php +++ b/src/Model/Nosto/Entity/Person/BuilderInterface.php @@ -18,7 +18,7 @@ public function build( $customerGroup = null, $dateOfBirth = null, $gender = null, - $customerReference = null + $customerReference = null, ): ?AbstractPerson; public function buildObject( @@ -31,6 +31,6 @@ public function buildObject( $customerGroup = null, $dateOfBirth = null, $gender = null, - $customerReference = null + $customerReference = null, ): AbstractPerson; } diff --git a/src/Model/Nosto/Entity/Product/Builder.php b/src/Model/Nosto/Entity/Product/Builder.php index 49a3e060..bf3c72c7 100644 --- a/src/Model/Nosto/Entity/Product/Builder.php +++ b/src/Model/Nosto/Entity/Product/Builder.php @@ -64,7 +64,7 @@ public function __construct( TreeBuilderInterface $treeBuilder, EventDispatcherInterface $eventDispatcher, CrossSellingBuilderInterface $crossSellingBuilder, - EntityRepository $tagRepository + EntityRepository $tagRepository, ) { $this->seoUrlReplacer = $seoUrlReplacer; $this->configProvider = $configProvider; @@ -94,8 +94,9 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c } $nostoProduct->setProductId( - $this->configProvider->getProductIdentifier($channelId, $languageId) === 'product-number' ? - $product->getProductNumber() : $product->getId() + $this->configProvider->getProductIdentifier($channelId, $languageId) === 'product-number' + ? $product->getProductNumber() + : $product->getId(), ); $nostoProduct->addCustomField('productNumber', $product->getProductNumber()); $nostoProduct->addCustomField('productId', $product->getId()); @@ -167,7 +168,7 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c foreach ($product->getCustomFields() as $fieldName => $fieldOriginalValue) { // All non-scalar value should be serialized - $fieldValue = $fieldOriginalValue === null || \is_scalar($fieldOriginalValue) ? + $fieldValue = $fieldOriginalValue === null || is_scalar($fieldOriginalValue) ? $fieldOriginalValue : SerializationHelper::serialize($fieldOriginalValue); if (in_array($fieldName, $selectedCustomFieldsCustomFields) && $fieldValue !== null) { @@ -183,7 +184,7 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c if ($this->configProvider->isEnabledAlternateImages($channelId, $languageId)) { $alternateMediaUrls = $product->getMedia()->map( - fn (ProductMediaEntity $media) => $media->getMedia()->getUrl() + fn (ProductMediaEntity $media) => $media->getMedia()->getUrl(), ); $nostoProduct->setAlternateImageUrls(array_values($alternateMediaUrls)); } @@ -223,8 +224,8 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c [ 'release-date' => $product->getReleaseDate()?->format(Defaults::STORAGE_DATE_TIME_FORMAT), 'mfg-part-number' => $product->getManufacturerNumber(), - ] - ) + ], + ), ); } @@ -240,7 +241,7 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c private function setPrices( NostoProduct $nostoProdcut, SalesChannelProductEntity $product, - SalesChannelContext $context + SalesChannelContext $context, ): void { $productPrice = $product->getCalculatedPrices()->first() ?: $product->getCalculatedPrice(); if (!($productPrice instanceof CalculatedPrice)) { @@ -257,12 +258,12 @@ private function setPrices( if (!$isGross) { $price = $this->calculator->calculate( new QuantityPriceDefinition($unitPrice, $productPrice->getTaxRules(), 1), - $context->getItemRounding() + $context->getItemRounding(), ); $priceList = $this->calculator->calculate( new QuantityPriceDefinition($listPrice, $productPrice->getTaxRules(), 1), - $context->getItemRounding() + $context->getItemRounding(), ); $unitPrice = $listPrice = 0; @@ -279,12 +280,12 @@ private function setPrices( $nostoProdcut->setListPrice($this->priceRounding->cashRound($listPrice, $context->getItemRounding())); } - private function getProductUrl(ProductEntity $product, SalesChannelContext $context) + private function getProductUrl(ProductEntity $product, SalesChannelContext $context): ?string { if ($domains = $context->getSalesChannel()->getDomains()) { $domainId = (string) $this->configProvider->getDomainId( $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), ); $domain = $domains->has($domainId) ? $domains->get($domainId) : $domains->first(); $raw = $this->seoUrlReplacer->generate('frontend.detail.page', [ @@ -299,7 +300,7 @@ private function getProductUrl(ProductEntity $product, SalesChannelContext $cont private function initTags( ProductEntity $productEntity, NostoProduct $nostoProduct, - SalesChannelContext $context + SalesChannelContext $context, ): void { $tags = $this->loadTags($context->getContext()); $channelId = $context->getSalesChannelId(); @@ -308,17 +309,17 @@ private function initTags( $nostoProduct->setTag1($this->getTagValues( $productEntity, $this->configProvider->getTagFieldKey(1, $channelId, $languageId), - $tags + $tags, )); $nostoProduct->setTag2($this->getTagValues( $productEntity, $this->configProvider->getTagFieldKey(2, $channelId, $languageId), - $tags + $tags, )); $nostoProduct->setTag3($this->getTagValues( $productEntity, $this->configProvider->getTagFieldKey(3, $channelId, $languageId), - $tags + $tags, )); } @@ -349,7 +350,7 @@ private function getCategoryIds(CategoryCollection $categoriesRo): array return array_values( array_map(function (CategoryEntity $category) { return $category->getId(); - }, $categoriesRo->getElements()) + }, $categoriesRo->getElements()), ); } } diff --git a/src/Model/Nosto/Entity/Product/CachedProvider.php b/src/Model/Nosto/Entity/Product/CachedProvider.php index 79696001..8bfe6fc3 100644 --- a/src/Model/Nosto/Entity/Product/CachedProvider.php +++ b/src/Model/Nosto/Entity/Product/CachedProvider.php @@ -20,7 +20,7 @@ class CachedProvider implements ProductProviderInterface public function __construct( TagAwareAdapterInterface $cache, - Provider $innerProvider + Provider $innerProvider, ) { $this->cache = $cache; $this->innerProvider = $innerProvider; diff --git a/src/Model/Nosto/Entity/Product/Category/TreeBuilder.php b/src/Model/Nosto/Entity/Product/Category/TreeBuilder.php index c4d6fd2e..b9ae27a0 100644 --- a/src/Model/Nosto/Entity/Product/Category/TreeBuilder.php +++ b/src/Model/Nosto/Entity/Product/Category/TreeBuilder.php @@ -13,19 +13,19 @@ public function fromCategoriesRo(CategoryCollection $categoriesRo): array { $categoryNameSets = $this->getCategoryNameSets($categoriesRo); - $nostoCategoryNames = \array_map(function (array $nameSet) { + $nostoCategoryNames = array_map(function (array $nameSet) { return array_reduce( $nameSet, function (array $acc, $categoryName) { - $acc[] = (string) end($acc) . '/' . $categoryName; + $acc[] = end($acc) . '/' . $categoryName; return $acc; }, - [] + [], ); }, $categoryNameSets); - return \array_values(\array_unique(array_merge([], ...array_values($nostoCategoryNames)))); + return array_values(array_unique(array_merge([], ...array_values($nostoCategoryNames)))); } public function fromCategoriesRoWithId(CategoryCollection $categoriesRo): array @@ -51,11 +51,11 @@ private function getCategoryNameSets(CategoryCollection $categoriesRo): array ->filter(fn (CategoryEntity $category) => $category->getParentId() === null) ->first()->getId(); - return \array_filter(\array_map(function (CategoryEntity $category) use ($rootCategoryId) { - return \array_filter( + return array_filter(array_map(function (CategoryEntity $category) use ($rootCategoryId) { + return array_filter( $category->getPlainBreadcrumb(), fn (string $categoryId) => $categoryId !== $rootCategoryId, - ARRAY_FILTER_USE_KEY + ARRAY_FILTER_USE_KEY, ); }, $categoriesRo->getElements())); } diff --git a/src/Model/Nosto/Entity/Product/CrossSelling/CrossSellingBuilder.php b/src/Model/Nosto/Entity/Product/CrossSelling/CrossSellingBuilder.php index e974f023..d126c38c 100644 --- a/src/Model/Nosto/Entity/Product/CrossSelling/CrossSellingBuilder.php +++ b/src/Model/Nosto/Entity/Product/CrossSelling/CrossSellingBuilder.php @@ -20,7 +20,6 @@ use Shopware\Core\System\SalesChannel\SalesChannelContext; use Shopware\Core\System\SystemConfig\SystemConfigService; use Symfony\Component\DependencyInjection\ContainerInterface; -use function count; class CrossSellingBuilder implements CrossSellingBuilderInterface { @@ -42,7 +41,7 @@ public function __construct( SalesChannelRepository $productRepository, SystemConfigService $systemConfigService, ConfigProvider $configProvider, - ContainerInterface $container + ContainerInterface $container, ) { $this->crossSellingRepository = $crossSellingRepository; $this->productStreamBuilder = $productStreamBuilder; @@ -58,7 +57,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(), @@ -73,7 +74,7 @@ private function loadCrossSellings(string $productId, SalesChannelContext $conte { $syncConfig = $this->configProvider->getCrossSellingSyncOption( $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), ); if ($syncConfig === 'no-sync') { return new ProductCrossSellingCollection(); @@ -102,14 +103,17 @@ private function useProductStream(ProductCrossSellingEntity $crossSelling): bool && $crossSelling->getProductStreamId() !== null; } - protected function loadByStream(ProductCrossSellingEntity $crossSelling, SalesChannelContext $context, Criteria $criteria): array - { + protected function loadByStream( + ProductCrossSellingEntity $crossSelling, + SalesChannelContext $context, + Criteria $criteria, + ): array { /** @var string $productStreamId */ $productStreamId = $crossSelling->getProductStreamId(); $filters = $this->productStreamBuilder->buildFilters( $productStreamId, - $context->getContext() + $context->getContext(), ); $criteria->addFilter(...$filters) @@ -140,8 +144,11 @@ private function handleAvailableStock(Criteria $criteria, SalesChannelContext $c return $criteria; } - protected function loadByIds(ProductCrossSellingEntity $crossSelling, SalesChannelContext $context, Criteria $criteria): array - { + protected function loadByIds( + ProductCrossSellingEntity $crossSelling, + SalesChannelContext $context, + Criteria $criteria, + ): array { if (!$crossSelling->getAssignedProducts()) { return []; } @@ -152,7 +159,7 @@ protected function loadByIds(ProductCrossSellingEntity $crossSelling, SalesChann $filter = new ProductAvailableFilter( $context->getSalesChannel()->getId(), - ProductVisibilityDefinition::VISIBILITY_LINK + ProductVisibilityDefinition::VISIBILITY_LINK, ); if (!count($ids)) { diff --git a/src/Model/Nosto/Entity/Product/Event/NostoProductBuiltEvent.php b/src/Model/Nosto/Entity/Product/Event/NostoProductBuiltEvent.php index 45e1cbcf..21f4e583 100644 --- a/src/Model/Nosto/Entity/Product/Event/NostoProductBuiltEvent.php +++ b/src/Model/Nosto/Entity/Product/Event/NostoProductBuiltEvent.php @@ -22,7 +22,7 @@ class NostoProductBuiltEvent extends NestedEvent implements ShopwareSalesChannel public function __construct( ProductEntity $product, NostoProduct $nostoProduct, - SalesChannelContext $salesChannelContext + SalesChannelContext $salesChannelContext, ) { $this->product = $product; $this->nostoProduct = $nostoProduct; diff --git a/src/Model/Nosto/Entity/Product/SkuBuilder.php b/src/Model/Nosto/Entity/Product/SkuBuilder.php index 89ef1d5c..80a93d2e 100644 --- a/src/Model/Nosto/Entity/Product/SkuBuilder.php +++ b/src/Model/Nosto/Entity/Product/SkuBuilder.php @@ -29,7 +29,7 @@ public function build(ProductEntity $product, SalesChannelContext $context): Nos $nostoSku->setId( $this->configProvider->getProductIdentifier($channelId, $languageId) === 'product-number' ? $product->getProductNumber() - : $product->getId() + : $product->getId(), ); $nostoSku->addCustomField('productNumber', $product->getProductNumber()); $nostoSku->addCustomField('productId', $product->getId()); @@ -83,8 +83,8 @@ public function build(ProductEntity $product, SalesChannelContext $context): Nos [ 'release-date' => $product->getReleaseDate()?->format(Defaults::STORAGE_DATE_TIME_FORMAT), 'mfg-part-number' => $product->getManufacturerNumber(), - ] - ) + ], + ), ); } diff --git a/src/Model/Operation/EntityChangelogSyncHandler.php b/src/Model/Operation/EntityChangelogSyncHandler.php index aa929b65..6b40fa66 100644 --- a/src/Model/Operation/EntityChangelogSyncHandler.php +++ b/src/Model/Operation/EntityChangelogSyncHandler.php @@ -33,7 +33,7 @@ class EntityChangelogSyncHandler implements JobHandlerInterface, GeneratingHandl public function __construct( EntityRepository $entityChangelogRepository, - JobScheduler $jobScheduler + JobScheduler $jobScheduler, ) { $this->entityChangelogRepository = $entityChangelogRepository; $this->jobScheduler = $jobScheduler; @@ -53,22 +53,26 @@ public function execute(object $message): JobResult return $result; } - private function processMarketingPermissionEvents(Context $context, JobResult $result, string $parentJobId) + private function processMarketingPermissionEvents(Context $context, JobResult $result, string $parentJobId): void { $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( - \sprintf( + sprintf( 'Job with payload of %s marketing permission updates has been scheduled.', - count($subscriberIds) - ) + count($subscriberIds), + ), )); }); } - private function processEventBatches(Context $context, string $entityType, callable $processCallback) + private function processEventBatches(Context $context, string $entityType, callable $processCallback): void { $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('entityType', $entityType)); @@ -95,7 +99,7 @@ private function processEventBatches(Context $context, string $entityType, calla } } - private function processNewOrderEvents(Context $context, JobResult $result, string $parentJobId) + private function processNewOrderEvents(Context $context, JobResult $result, string $parentJobId): void { $type = EventsWriter::ORDER_ENTITY_PLACED_NAME; $this->processEventBatches($context, $type, function (array $orderIds) use ($parentJobId, $result, $context) { @@ -105,16 +109,16 @@ private function processNewOrderEvents(Context $context, JobResult $result, stri $orderIds, [], $context, - 'New Order Sync Operation' + 'New Order Sync Operation', ); $this->jobScheduler->schedule($jobMessage); $result->addMessage(new InfoMessage( - \sprintf('Job with payload of %s new orders has been scheduled.', count($orderIds)) + sprintf('Job with payload of %s new orders has been scheduled.', count($orderIds)), )); }); } - private function processUpdatedOrderEvents(Context $context, JobResult $result, string $parentJobId) + private function processUpdatedOrderEvents(Context $context, JobResult $result, string $parentJobId): void { $type = EventsWriter::ORDER_ENTITY_UPDATED_NAME; $this->processEventBatches($context, $type, function (array $orderIds) use ($parentJobId, $result, $context) { @@ -124,23 +128,23 @@ private function processUpdatedOrderEvents(Context $context, JobResult $result, [], $orderIds, $context, - 'Updated Order Sync Operation' + 'Updated Order Sync Operation', ); $this->jobScheduler->schedule($jobMessage); $result->addMessage(new InfoMessage( - \sprintf('Job with payload of %s updated orders has been scheduled.', count($orderIds)) + sprintf('Job with payload of %s updated orders has been scheduled.', count($orderIds)), )); }); } - private function processProductEvents(Context $context, JobResult $result, string $parentJobId) + private function processProductEvents(Context $context, JobResult $result, string $parentJobId): void { $type = EventsWriter::PRODUCT_ENTITY_NAME; $this->processEventBatches($context, $type, function (array $productIds) use ($parentJobId, $result, $context) { $jobMessage = new ProductSyncMessage(Uuid::randomHex(), $parentJobId, $productIds, $context); $this->jobScheduler->schedule($jobMessage); $result->addMessage(new InfoMessage( - \sprintf('Job with payload of %s updated products has been scheduled.', count($productIds)) + sprintf('Job with payload of %s updated products has been scheduled.', count($productIds)), )); }); } diff --git a/src/Model/Operation/Event/BeforeOperationEvent.php b/src/Model/Operation/Event/BeforeOperationEvent.php index 3547b7eb..de805ef9 100644 --- a/src/Model/Operation/Event/BeforeOperationEvent.php +++ b/src/Model/Operation/Event/BeforeOperationEvent.php @@ -16,7 +16,7 @@ class BeforeOperationEvent extends NestedEvent public function __construct( AbstractOperation $operation, - Context $context + Context $context, ) { $this->operation = $operation; $this->context = $context; diff --git a/src/Model/Operation/FullCatalogSyncHandler.php b/src/Model/Operation/FullCatalogSyncHandler.php index 8ab93fcd..da90f629 100644 --- a/src/Model/Operation/FullCatalogSyncHandler.php +++ b/src/Model/Operation/FullCatalogSyncHandler.php @@ -29,7 +29,7 @@ class FullCatalogSyncHandler implements JobHandlerInterface, GeneratingHandlerIn public function __construct( EntityRepository $productRepository, - JobScheduler $jobScheduler + JobScheduler $jobScheduler, ) { $this->productRepository = $productRepository; $this->jobScheduler = $jobScheduler; @@ -47,14 +47,15 @@ public function execute(object $message): JobResult $result->addMessage(new InfoMessage('Child job generation started.')); while (($products = $repositoryIterator->fetch()) !== null) { - if (is_int($products)) { - continue; - } - $jobMessage = new ProductSyncMessage(Uuid::randomHex(), $message->getJobId(), $this->getIdsForMessage($products->getEntities()), $message->getContext()); - $this->jobScheduler->schedule($jobMessage); - $result->addMessage(new InfoMessage( - \sprintf('Job with payload of products has been scheduled.') - )); + $this->jobScheduler->schedule( + new ProductSyncMessage( + Uuid::randomHex(), + $message->getJobId(), + $this->getIdsForMessage($products->getEntities()), + $message->getContext(), + ), + ); + $result->addMessage(new InfoMessage('Job with payload of products has been scheduled.')); } return $result; diff --git a/src/Model/Operation/MarketingPermissionSyncHandler.php b/src/Model/Operation/MarketingPermissionSyncHandler.php index 05021d9d..3568d779 100644 --- a/src/Model/Operation/MarketingPermissionSyncHandler.php +++ b/src/Model/Operation/MarketingPermissionSyncHandler.php @@ -16,6 +16,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter; use Shopware\Core\Framework\DataAbstractionLayer\{EntityCollection, EntityRepository}; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Throwable; class MarketingPermissionSyncHandler implements JobHandlerInterface { @@ -30,7 +31,7 @@ class MarketingPermissionSyncHandler implements JobHandlerInterface public function __construct( EntityRepository $newsletterRecipientRepository, Account\Provider $accountProvider, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $eventDispatcher, ) { $this->newsletterRecipientRepository = $newsletterRecipientRepository; $this->accountProvider = $accountProvider; @@ -48,7 +49,7 @@ public function execute(object $message): JobResult $accountOperationResult = $this->doOperation( $nostoAccount, $message->getContext(), - $message->getNewsletterRecipientIds() + $message->getNewsletterRecipientIds(), ); foreach ($accountOperationResult->getErrors() as $error) { $operationResult->addError($error); @@ -68,7 +69,7 @@ private function doOperation(AccountInterface $account, Context $context, array [ NewsletterSubscribeRoute::OPTION_DIRECT, NewsletterSubscribeRoute::STATUS_OPT_IN, - ] + ], ); try { $this->eventDispatcher->dispatch( @@ -78,11 +79,11 @@ private function doOperation(AccountInterface $account, Context $context, array 'email' => $subscriber->getEmail(), 'isSubscribed' => $isSubscribed, ], - $context - ) + $context, + ), ); $operation->update($subscriber->getEmail(), $isSubscribed); - } catch (\Throwable $e) { + } catch (Throwable $e) { $result->addError($e); } } diff --git a/src/Model/Operation/OrderSyncHandler.php b/src/Model/Operation/OrderSyncHandler.php index 29a0fb70..e8eacc08 100644 --- a/src/Model/Operation/OrderSyncHandler.php +++ b/src/Model/Operation/OrderSyncHandler.php @@ -19,6 +19,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter; use Shopware\Core\Framework\DataAbstractionLayer\{EntityCollection, EntityRepository}; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Throwable; class OrderSyncHandler implements JobHandlerInterface { @@ -39,7 +40,7 @@ public function __construct( Account\Provider $accountProvider, NostoOrderBuilderInterface $nostoOrderbuilder, NostoOrderStatusBuilderInterface $nostoOrderStatusBuilder, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $eventDispatcher, ) { $this->orderRepository = $orderRepository; $this->accountProvider = $accountProvider; @@ -70,14 +71,14 @@ private function doOperation(Account $account, Context $context, object $message foreach ($this->getOrders($context, $message->getNewOrderIds()) as $order) { try { $this->sendNewOrder($order, $account, $context); - } catch (\Throwable $e) { + } catch (Throwable $e) { $result->addError($e); } } foreach ($this->getOrders($context, $message->getUpdatedOrderIds()) as $order) { try { $this->sendUpdatedOrder($order, $account); - } catch (\Throwable $e) { + } catch (Throwable $e) { $result->addError($e); } } @@ -105,7 +106,12 @@ private function sendNewOrder(OrderEntity $order, Account $account, Context $con $nostoOrder = $this->nostoOrderbuilder->build($order, $context); $nostoCustomerId = $order->getOrderCustomer()->getCustomerId(); $nostoCustomerIdentifier = AbstractGraphQLOperation::IDENTIFIER_BY_REF; - $operation = new OrderCreate($nostoOrder, $account->getNostoAccount(), $nostoCustomerIdentifier, $nostoCustomerId); + $operation = new OrderCreate( + $nostoOrder, + $account->getNostoAccount(), + $nostoCustomerIdentifier, + $nostoCustomerId, + ); $this->eventDispatcher->dispatch(new BeforeOrderCreatedEvent($operation, $context)); $operation->execute(); } diff --git a/src/Model/Operation/ProductSyncHandler.php b/src/Model/Operation/ProductSyncHandler.php index f404e30d..713fbde2 100644 --- a/src/Model/Operation/ProductSyncHandler.php +++ b/src/Model/Operation/ProductSyncHandler.php @@ -36,6 +36,7 @@ use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Throwable; class ProductSyncHandler implements Job\JobHandlerInterface { @@ -43,8 +44,6 @@ class ProductSyncHandler implements Job\JobHandlerInterface public const PRODUCT_ASSIGNMENT_TYPE = 'productAssignmentType'; - private SalesChannelRepository $productRepository; - private AbstractSalesChannelContextFactory $channelContextFactory; private ProductProviderInterface $productProvider; @@ -62,7 +61,6 @@ class ProductSyncHandler implements Job\JobHandlerInterface private SalesChannelRepository $categoryRepository; public function __construct( - SalesChannelRepository $productRepository, AbstractSalesChannelContextFactory $channelContextFactory, ProductProviderInterface $productProvider, Account\Provider $accountProvider, @@ -70,9 +68,8 @@ public function __construct( AbstractRuleLoader $ruleLoader, ProductHelper $productHelper, EventDispatcherInterface $eventDispatcher, - SalesChannelRepository $categoryRepository + SalesChannelRepository $categoryRepository, ) { - $this->productRepository = $productRepository; $this->channelContextFactory = $channelContextFactory; $this->productProvider = $productProvider; $this->accountProvider = $accountProvider; @@ -96,7 +93,7 @@ public function execute(object $message): Job\JobResult $account->getChannelId(), [ SalesChannelContextService::LANGUAGE_ID => $account->getLanguageId(), - ] + ], ); $channelContext->setRuleIds($this->loadRuleIds($channelContext)); @@ -114,7 +111,7 @@ private function loadRuleIds(SalesChannelContext $channelContext): array return $this->ruleLoader->load($channelContext->getContext())->filter( function (RuleEntity $rule) use ($channelContext) { return $rule->getPayload()->match(new CheckoutRuleScope($channelContext)); - } + }, )->getIds(); } @@ -124,7 +121,7 @@ private function doOperation(Account $account, SalesChannelContext $context, arr $result = new Job\JobResult(); $existentProductsCollection = $this->productHelper->loadProducts($productIds, $context); $deletedProductIds = array_diff($productIds, $existentProductsCollection->getIds()); - $existentParentProductIds = \array_map(function (ProductEntity $product) { + $existentParentProductIds = array_map(function (ProductEntity $product) { return $product->getParentId() === null ? $product->getId() : $product->getParentId(); }, $existentProductsCollection->getElements()); @@ -138,7 +135,7 @@ private function doOperation(Account $account, SalesChannelContext $context, arr if (!empty($deletedProductIds)) { $this->doDeleteOperation($account, $context, $deletedProductIds, $ids); } - } catch (\Throwable $e) { + } catch (Throwable $e) { $result->addError($e); } @@ -154,12 +151,12 @@ private function doUpsertOperation( SalesChannelContext $context, ProductCollection $productCollection, Job\JobResult $result, - array $ids + array $ids, ): void { $domainUrl = $this->getDomainUrl( $context->getSalesChannel()->getDomains(), $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), ); $domain = parse_url($domainUrl, PHP_URL_HOST); $operation = new UpsertProduct($account->getNostoAccount(), $domain); @@ -211,7 +208,7 @@ private function doUpsertOperation( foreach ($nostoProducts as $preparedProductForSync) { $invalidMessage = $this->validateProduct( $preparedProductForSync->getProductId(), - $preparedProductForSync + $preparedProductForSync, ); if ($invalidMessage) { @@ -266,7 +263,7 @@ private function validateProduct(string $productNumber, NostoProduct $product): } return empty($message) ? null : new WarningMessage( - $message . 'ignoring upsert for product with number. ' . $productNumber + $message . 'ignoring upsert for product with number. ' . $productNumber, ); } @@ -274,13 +271,13 @@ private function doDeleteOperation( Account $account, SalesChannelContext $context, array $productIds, - array $mapping + array $mapping, ): void { $identifiers = $this->getIdentifiers($context, $productIds, $mapping); $domainUrl = $this->getDomainUrl( $context->getSalesChannel()->getDomains(), $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), ); $domain = parse_url($domainUrl, PHP_URL_HOST); @@ -294,7 +291,7 @@ private function getIdentifiers(SalesChannelContext $context, array $productIds, { $identifierType = $this->configProvider->getProductIdentifier( $context->getSalesChannelId(), - $context->getLanguageId() + $context->getLanguageId(), ); if ($identifierType === 'product-number') { return $this->getProductNumbers($productIds, $mapping); @@ -319,7 +316,7 @@ private function getProductNumbers(array $productIds, array $mapping): array private function getDomainUrl( ?SalesChannelDomainCollection $domains, ?string $channelId, - ?string $languageId + ?string $languageId, ): string { if ($domains == null || $domains->count() < 1) { return ''; @@ -334,7 +331,7 @@ private function getCategoryIdsByDynamicGroups(SalesChannelContext $context): ar { $criteria = new Criteria(); $criteria->addFilter( - new EqualsFilter(self::PRODUCT_ASSIGNMENT_TYPE, CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM) + new EqualsFilter(self::PRODUCT_ASSIGNMENT_TYPE, CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM), ); $categories = $this->categoryRepository->search($criteria, $context)->getEntities(); @@ -359,7 +356,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(); diff --git a/src/NostoIntegration.php b/src/NostoIntegration.php index fdfd6ab6..e149cd41 100644 --- a/src/NostoIntegration.php +++ b/src/NostoIntegration.php @@ -6,6 +6,7 @@ use Composer\Autoload\ClassLoader; use Nosto\Scheduler\NostoScheduler; +use ReflectionClass; use Shopware\Core\Framework\Parameter\AdditionalBundleParameters; use Shopware\Core\Framework\Plugin; use Shopware\Core\Framework\Plugin\Context\ActivateContext; @@ -54,7 +55,7 @@ public function activate(ActivateContext $activateContext): void foreach ($this->getDependencyBundles() as $bundle) { $migrationHelper->getMigrationCollection($bundle)->migrateInPlace(); - $assetService->copyAssetsFromBundle((new \ReflectionClass($bundle))->getShortName()); + $assetService->copyAssetsFromBundle((new ReflectionClass($bundle))->getShortName()); } } @@ -80,14 +81,14 @@ public function uninstall(UninstallContext $uninstallContext): void continue; } - $schedulerDependencies = \array_filter( + $schedulerDependencies = array_filter( $bundle->getAdditionalBundles($bundleParameters), function (BundleInterface $bundle) { return $bundle instanceof NostoScheduler; - } + }, ); - if (\count($schedulerDependencies) !== 0) { + if (count($schedulerDependencies) !== 0) { $hasOtherSchedulerDependency = true; break; } @@ -118,7 +119,7 @@ public static function classLoader(): void } $classLoader->unregister(); - $classLoader->register(false); + $classLoader->register(); } public function build(ContainerBuilder $container): void @@ -135,7 +136,7 @@ public function build(ContainerBuilder $container): void $configLoader = new DelegatingLoader($resolver); - $confDir = \rtrim($this->getPath(), '/') . '/Resources/config'; + $confDir = rtrim($this->getPath(), '/') . '/Resources/config'; $configLoader->load($confDir . '/{packages}/*.yaml', 'glob'); } diff --git a/src/Search/Api/SearchService.php b/src/Search/Api/SearchService.php index 3dbd457c..b811df01 100644 --- a/src/Search/Api/SearchService.php +++ b/src/Search/Api/SearchService.php @@ -74,7 +74,7 @@ protected function allowRequest(Request $request, SalesChannelContext $context): return SearchHelper::shouldHandleRequest( $context, $this->configProvider, - SearchHelper::isNavigationPage($request) + SearchHelper::isNavigationPage($request), ); } @@ -94,7 +94,7 @@ protected function fetchFilters( Request $request, Criteria $criteria, SalesChannelContext $context, - AbstractRequestHandler $requestHandler + AbstractRequestHandler $requestHandler, ): void { try { $response = $requestHandler->sendRequest($request, $criteria, $context, self::FILTER_REQUEST_LIMIT); @@ -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()), ); } } @@ -118,7 +118,7 @@ protected function fetchSelectableFilters( Request $request, Criteria $criteria, SalesChannelContext $context, - AbstractRequestHandler $requestHandler + AbstractRequestHandler $requestHandler, ): void { try { $response = $requestHandler->sendRequest($request, $criteria, $context, self::FILTER_REQUEST_LIMIT); @@ -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()), ); } } diff --git a/src/Search/Request/Handler/AbstractRequestHandler.php b/src/Search/Request/Handler/AbstractRequestHandler.php index d0a59e05..b7dcad03 100644 --- a/src/Search/Request/Handler/AbstractRequestHandler.php +++ b/src/Search/Request/Handler/AbstractRequestHandler.php @@ -20,7 +20,7 @@ public function __construct( protected readonly ConfigProvider $configProvider, protected readonly SortingHandlerService $sortingHandlerService, protected readonly Logger $logger, - protected ?FilterHandler $filterHandler = null + protected ?FilterHandler $filterHandler = null, ) { $this->filterHandler = $filterHandler ?? new FilterHandler(); } @@ -34,7 +34,7 @@ abstract public function sendRequest( Request $request, Criteria $criteria, SalesChannelContext $context, - ?int $limit = null + ?int $limit = null, ): SearchResult; public function fetchProducts(Request $request, Criteria $criteria, SalesChannelContext $context): void @@ -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; } @@ -63,12 +63,16 @@ public function fetchProducts(Request $request, Criteria $criteria, SalesChannel $criteria, $responseParser, $originalCriteria->getLimit(), - $originalCriteria->getOffset() + $originalCriteria->getOffset(), ); } - protected function setDefaultParams(Request $request, Criteria $criteria, SearchRequest $searchRequest, ?int $limit = null): void - { + protected function setDefaultParams( + Request $request, + Criteria $criteria, + SearchRequest $searchRequest, + ?int $limit = null, + ): void { $this->setPaginationParams($criteria, $searchRequest, $limit); $this->setSessionParamsFromCookies($request, $searchRequest); $this->sortingHandlerService->handle($searchRequest, $criteria); @@ -90,7 +94,7 @@ protected function setPagination( Criteria $criteria, GraphQLResponseParser $responseParser, ?int $limit, - ?int $offset + ?int $offset, ): void { $pagination = $responseParser->getPaginationExtension($limit, $offset); $criteria->addExtension('nostoPagination', $pagination); diff --git a/src/Search/Request/Handler/FilterHandler.php b/src/Search/Request/Handler/FilterHandler.php index 537ad370..93d5aa6b 100644 --- a/src/Search/Request/Handler/FilterHandler.php +++ b/src/Search/Request/Handler/FilterHandler.php @@ -11,10 +11,7 @@ use Nosto\NostoIntegration\Struct\FiltersExtension; use Nosto\NostoIntegration\Struct\IdToFieldMapping; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; - use Symfony\Component\HttpFoundation\Request; -use function array_merge; -use function in_array; class FilterHandler { @@ -30,7 +27,7 @@ class FilterHandler public function handleFilters( Request $request, Criteria $criteria, - SearchRequest $searchNavigationRequest + SearchRequest $searchNavigationRequest, ): void { $selectedFilters = $request->query->all(); $availableFilterIds = $this->fetchAvailableFilterIds($criteria); @@ -49,7 +46,7 @@ public function handleFilters( $filterValue, $searchNavigationRequest, $availableFilterIds, - $filterMapping + $filterMapping, ); } } @@ -61,7 +58,7 @@ protected function handleFilter( string $filterValue, SearchRequest $searchNavigationRequest, array $availableFilterIds, - IdToFieldMapping $filterMapping + IdToFieldMapping $filterMapping, ): void { // Range Slider filters in Shopware are prefixed with min-/max-. We manually need to remove this and send // the appropriate parameters to our API. @@ -95,7 +92,7 @@ protected function handleRangeSliderFilter( if (mb_strpos($filterId, self::MIN_PREFIX) === 0) { $filterId = mb_substr($filterId, mb_strlen(self::MIN_PREFIX)); $filterField = $fieldMapping->getMapping($filterId); - $searchNavigationRequest->addRangeFilter($filterField, $filterValue, null); + $searchNavigationRequest->addRangeFilter($filterField, $filterValue); } else { $filterId = mb_substr($filterId, mb_strlen(self::MAX_PREFIX)); $filterField = $fieldMapping->getMapping($filterId); @@ -182,7 +179,7 @@ public function handleAvailableFilters(Criteria $criteria): array private function parseNostoFiltersForShopware( FiltersExtension $availableFilters, - FiltersExtension $allFilters + FiltersExtension $allFilters, ): array { $result = []; diff --git a/src/Search/Request/Handler/NavigationRequestHandler.php b/src/Search/Request/Handler/NavigationRequestHandler.php index 98de9646..c6624ed7 100644 --- a/src/Search/Request/Handler/NavigationRequestHandler.php +++ b/src/Search/Request/Handler/NavigationRequestHandler.php @@ -16,7 +16,7 @@ public function sendRequest( Request $request, Criteria $criteria, SalesChannelContext $context, - ?int $limit = null + ?int $limit = null, ): SearchResult { $searchRequest = new SearchRequest($this->configProvider, $context); $this->setDefaultParams($request, $criteria, $searchRequest, $limit); diff --git a/src/Search/Request/Handler/SearchRequestHandler.php b/src/Search/Request/Handler/SearchRequestHandler.php index ad537178..884346ad 100644 --- a/src/Search/Request/Handler/SearchRequestHandler.php +++ b/src/Search/Request/Handler/SearchRequestHandler.php @@ -17,7 +17,7 @@ public function sendRequest( Request $request, Criteria $criteria, SalesChannelContext $context, - ?int $limit = null + ?int $limit = null, ): SearchResult { $searchRequest = new SearchRequest($this->configProvider, $context); $this->setDefaultParams($request, $criteria, $searchRequest, $limit); @@ -31,7 +31,7 @@ protected function handleRedirect(SalesChannelContext $context, Redirect $redire { $context->getContext()->addExtension( 'nostoRedirect', - $redirectExtension + $redirectExtension, ); } } diff --git a/src/Search/Request/Handler/SortHandlers/SortingHandlerInterface.php b/src/Search/Request/Handler/SortHandlers/SortingHandlerInterface.php index 4a725f0f..0bc2a549 100644 --- a/src/Search/Request/Handler/SortHandlers/SortingHandlerInterface.php +++ b/src/Search/Request/Handler/SortHandlers/SortingHandlerInterface.php @@ -13,6 +13,6 @@ public function supportsSorting(FieldSorting $fieldSorting): bool; public function generateSorting( FieldSorting $fieldSorting, - SearchRequest $searchNavigationRequest + SearchRequest $searchNavigationRequest, ): void; } diff --git a/src/Search/Request/SearchRequest.php b/src/Search/Request/SearchRequest.php index 8b30d92a..f2618053 100644 --- a/src/Search/Request/SearchRequest.php +++ b/src/Search/Request/SearchRequest.php @@ -22,7 +22,7 @@ public function __construct( $account = new Account($this->configProvider->getAccountName($channelId, $languageId)); $account->addApiToken( - new Token(Token::API_SEARCH, $this->configProvider->getSearchToken($channelId, $languageId)) + new Token(Token::API_SEARCH, $this->configProvider->getSearchToken($channelId, $languageId)), ); parent::__construct($account); @@ -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] = [ @@ -111,12 +111,12 @@ public function setSessionParams(array $sessionParams): void $this->sessionParams = $sessionParams; } - protected function getResultHandler() + protected function getResultHandler(): SearchResultHandler { return new SearchResultHandler(); } - public function getQuery() + public function getQuery(): string { return << $product->getProductId(), - $this->searchResult->getProducts()->getHits() + $this->searchResult->getProducts()->getHits(), ); } } diff --git a/src/Service/CategoryMerchandising/MerchandisingSearchApi.php b/src/Service/CategoryMerchandising/MerchandisingSearchApi.php index c5afffa7..cd79151e 100644 --- a/src/Service/CategoryMerchandising/MerchandisingSearchApi.php +++ b/src/Service/CategoryMerchandising/MerchandisingSearchApi.php @@ -44,7 +44,7 @@ public function __construct( private readonly SessionLookupResolver $resolver, private readonly ConfigProvider $configProvider, private readonly RequestStack $requestStack, - private readonly LoggerInterface $logger + private readonly LoggerInterface $logger, ) { } @@ -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), ); } @@ -100,7 +100,7 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC $category = $this->categoryRepository->search( new Criteria([$categoryId]), - $salesChannelContext->getContext() + $salesChannelContext->getContext(), )->first(); $this->currentCategoryId = $categoryId; @@ -112,7 +112,7 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC $includeFilters = !empty($criteria->getPostFilters()) ? $this->filterTranslator->buildIncludeFilters( $criteria->getPostFilters(), - $salesChannelContext->getContext() + $salesChannelContext->getContext(), ) : new IncludeFilters(); @@ -132,14 +132,14 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC AbstractGraphQLOperation::IDENTIFIER_BY_CID, false, $criteria->getLimit(), - '' + '', ); /** @var CategoryMerchandisingResult $result */ $result = $operation->execute(); if (!$result->getTotalPrimaryCount()) { - throw new \Exception('There are no products from the Nosto.'); + throw new Exception('There are no products from the Nosto.'); } if ($this->configProvider->getProductIdentifier($channelId, $languageId) === 'product-number') { @@ -150,12 +150,12 @@ public function searchIds(Criteria $criteria, SalesChannelContext $salesChannelC $result->getTotalPrimaryCount(), $this->resultTranslator->getProductIds($result), $criteria, - $salesChannelContext->getContext() + $salesChannelContext->getContext(), ); } catch (Exception $e) { $this->logger->error( $e->getMessage(), - ContextHelper::createContextFromException($e) + ContextHelper::createContextFromException($e), ); return $this->repository->searchIds($criteria, $salesChannelContext); @@ -209,7 +209,7 @@ private function replaceSkusWithActualIds($result, $context): CategoryMerchandis // Check if uuid doesn't cause a crash. This is mostly to prevent a page crash in edge cases. Uuid::fromHexToBytes($productToChangeData->getProductId()); $newResultSet->append($productToChangeData); - } catch (Exception $e) { + } catch (Exception) { // Nothing. Just skip. } } @@ -219,7 +219,7 @@ private function replaceSkusWithActualIds($result, $context): CategoryMerchandis $newResultSet, $result->getTrackingCode(), $result->getTotalPrimaryCount(), - $result->getBatchToken() + $result->getBatchToken(), ); } @@ -260,7 +260,7 @@ private function getCategoryId(Criteria $criteria): ?string private function getCategoryNameByBreadcrumbs($categoryBreadcrumbs): string { - $breadcrumbs = \array_slice($categoryBreadcrumbs, 1); + $breadcrumbs = array_slice($categoryBreadcrumbs, 1); $categoryFullName = ''; foreach ($breadcrumbs as $breadcrumb) { diff --git a/src/Service/CategoryMerchandising/NostoAwareCachedCategoryRoute.php b/src/Service/CategoryMerchandising/NostoAwareCachedCategoryRoute.php index 989ae754..f1792220 100644 --- a/src/Service/CategoryMerchandising/NostoAwareCachedCategoryRoute.php +++ b/src/Service/CategoryMerchandising/NostoAwareCachedCategoryRoute.php @@ -23,15 +23,15 @@ public function __construct(AbstractCategoryRoute $cachedCategoryRoute, NostoCac public function load( string $navigationId, Request $request, - SalesChannelContext $channelContext + SalesChannelContext $context, ): CategoryRouteResponse { - if ($this->cacheResolver->isCachingAllowedNoRoute($channelContext)) { + if ($this->cacheResolver->isCachingAllowedNoRoute($context)) { /** Allow caching */ - return $this->decoratedService->load($navigationId, $request, $channelContext); + return $this->decoratedService->load($navigationId, $request, $context); } /** Bypass the caching */ - return $this->getDecorated()->load($navigationId, $request, $channelContext); + return $this->getDecorated()->load($navigationId, $request, $context); } public function getDecorated(): AbstractCategoryRoute diff --git a/src/Service/CategoryMerchandising/NostoAwareCachedProductListingRoute.php b/src/Service/CategoryMerchandising/NostoAwareCachedProductListingRoute.php index 56eb1ded..756817e7 100644 --- a/src/Service/CategoryMerchandising/NostoAwareCachedProductListingRoute.php +++ b/src/Service/CategoryMerchandising/NostoAwareCachedProductListingRoute.php @@ -17,7 +17,7 @@ class NostoAwareCachedProductListingRoute extends AbstractProductListingRoute public function __construct( AbstractProductListingRoute $cachedProductListingRoute, - NostoCacheResolver $cacheResolver + NostoCacheResolver $cacheResolver, ) { $this->decoratedService = $cachedProductListingRoute; $this->cacheResolver = $cacheResolver; @@ -31,15 +31,15 @@ public function getDecorated(): AbstractProductListingRoute public function load( string $categoryId, Request $request, - SalesChannelContext $channelContext, - Criteria $criteria + SalesChannelContext $context, + Criteria $criteria, ): ProductListingRouteResponse { - if ($this->cacheResolver->isCachingAllowedNoRoute($channelContext)) { + if ($this->cacheResolver->isCachingAllowedNoRoute($context)) { /** Allow caching */ - return $this->decoratedService->load($categoryId, $request, $channelContext, $criteria); + return $this->decoratedService->load($categoryId, $request, $context, $criteria); } /** Bypass the caching */ - return $this->decoratedService->getDecorated()->load($categoryId, $request, $channelContext, $criteria); + return $this->decoratedService->getDecorated()->load($categoryId, $request, $context, $criteria); } } diff --git a/src/Service/CategoryMerchandising/NostoCacheResolver.php b/src/Service/CategoryMerchandising/NostoCacheResolver.php index 169a53b3..6c658934 100644 --- a/src/Service/CategoryMerchandising/NostoCacheResolver.php +++ b/src/Service/CategoryMerchandising/NostoCacheResolver.php @@ -20,7 +20,7 @@ class NostoCacheResolver public function __construct( RequestStack $requestStack, ConfigProvider $configProvider, - Provider $accountProvider + Provider $accountProvider, ) { $this->requestStack = $requestStack; $this->configProvider = $configProvider; @@ -62,16 +62,14 @@ public function isCachingAllowed(?SalesChannelContext $channelContext = null): b public function isCachingAllowedNoRoute(?SalesChannelContext $channelContext = null): bool { - $isCachingAllowed = true; - if (!$request = $this->requestStack->getCurrentRequest()) { - return $isCachingAllowed; + return true; } /** @var SalesChannelContext $channelContext */ $channelContext = $channelContext ?? $request->attributes->get('sw-sales-channel-context'); if (!$channelContext) { - return $isCachingAllowed; + return true; } if ($this->getBasicCachingAllowance($channelContext)) { @@ -80,10 +78,10 @@ public function isCachingAllowedNoRoute(?SalesChannelContext $channelContext = n $isLoggedIn = $channelContext->getCustomer() !== null; $isEnabledNotLoggedIdCache = $this->configProvider->isEnabledNotLoggedInCache($channelId, $languageId); - $isCachingAllowed = $isLoggedIn === true ? false : $isEnabledNotLoggedIdCache; + return !$isLoggedIn && $isEnabledNotLoggedIdCache; } - return $isCachingAllowed; + return true; } private function getBasicCachingAllowance(SalesChannelContext $channelContext): bool @@ -91,12 +89,12 @@ private function getBasicCachingAllowance(SalesChannelContext $channelContext): $channelId = $channelContext->getSalesChannelId(); $languageId = $channelContext->getLanguageId(); $isMerchEnabled = $this->configProvider->isMerchEnabled($channelId, $languageId); - $isNostoAccountExists = $this->accountProvider->get( + $nostoAccountExists = $this->accountProvider->get( $channelContext->getContext(), $channelId, $languageId, ) !== null; - return $isMerchEnabled && $isNostoAccountExists; + return $isMerchEnabled && $nostoAccountExists; } } diff --git a/src/Service/CategoryMerchandising/Translator/AttributeFilterTranslator.php b/src/Service/CategoryMerchandising/Translator/AttributeFilterTranslator.php index a726b64a..97a09e77 100644 --- a/src/Service/CategoryMerchandising/Translator/AttributeFilterTranslator.php +++ b/src/Service/CategoryMerchandising/Translator/AttributeFilterTranslator.php @@ -22,7 +22,7 @@ public function __construct(EntityRepository $propertyGroupOptionRepository) public function translate( IncludeFilters $includeFilters, MultiFilter $filters = null, - Context $context = null + Context $context = null, ): IncludeFilters { $optionAndPropertyIds = []; if (!$filters) { diff --git a/src/Service/CategoryMerchandising/Translator/ManufacturerFilterTranslator.php b/src/Service/CategoryMerchandising/Translator/ManufacturerFilterTranslator.php index 3b26e2fd..439c31f1 100644 --- a/src/Service/CategoryMerchandising/Translator/ManufacturerFilterTranslator.php +++ b/src/Service/CategoryMerchandising/Translator/ManufacturerFilterTranslator.php @@ -21,8 +21,11 @@ public function __construct(EntityRepository $manufacturerRepository) $this->manufacturerRepository = $manufacturerRepository; } - public function translate(IncludeFilters $includeFilters, EqualsAnyFilter $filters = null, Context $context = null): IncludeFilters - { + public function translate( + IncludeFilters $includeFilters, + EqualsAnyFilter $filters = null, + Context $context = null, + ): IncludeFilters { if (!$filters) { return $includeFilters; } diff --git a/src/Service/CategoryMerchandising/Translator/PriceFilterTranslator.php b/src/Service/CategoryMerchandising/Translator/PriceFilterTranslator.php index 0a64f43f..c84fba58 100644 --- a/src/Service/CategoryMerchandising/Translator/PriceFilterTranslator.php +++ b/src/Service/CategoryMerchandising/Translator/PriceFilterTranslator.php @@ -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")); diff --git a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php index 43b4cddb..5f4a012d 100644 --- a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php @@ -40,7 +40,7 @@ public function __construct( NostoConfigService $configService, NostoSyncRoute $nostoSyncRoute, TagAwareAdapterInterface $cache, - LoggerInterface $logger + LoggerInterface $logger, ) { parent::__construct($scheduledTaskRepository); $this->configProvider = $configProvider; @@ -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), ); } } @@ -108,7 +108,7 @@ private function isTodayAlreadyRun(): bool } return $lastSyncTimeObject->format(Defaults::STORAGE_DATE_FORMAT) === (new DateTime())->format( - Defaults::STORAGE_DATE_FORMAT + Defaults::STORAGE_DATE_FORMAT, ); } } diff --git a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php index 90881511..079bb4c8 100644 --- a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php @@ -17,7 +17,7 @@ class EntityChangelogScheduledTaskHandler extends ScheduledTaskHandler implement public function __construct( EntityRepository $scheduledTaskRepository, - JobScheduler $jobScheduler + JobScheduler $jobScheduler, ) { parent::__construct($scheduledTaskRepository); $this->jobScheduler = $jobScheduler; diff --git a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php index 9de8196c..6eafe58f 100644 --- a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php @@ -12,7 +12,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; -use function array_map; class OldJobCleanupScheduledTaskHandler extends ScheduledTaskHandler { @@ -20,7 +19,7 @@ class OldJobCleanupScheduledTaskHandler extends ScheduledTaskHandler public function __construct( EntityRepository $scheduledTaskRepository, - EntityRepository $jobRepository + EntityRepository $jobRepository, ) { parent::__construct($scheduledTaskRepository); $this->jobRepository = $jobRepository; @@ -42,8 +41,8 @@ public function run(): void 'createdAt', [ 'lt' => $numberOfDaysBeforeToday->format(Defaults::STORAGE_DATE_FORMAT), - ] - ) + ], + ), ); $idSearchResult = $this->jobRepository->searchIds($criteria, $context); diff --git a/src/Storefront/Checkout/Cart/RestoreUrlService/RestoreUrlService.php b/src/Storefront/Checkout/Cart/RestoreUrlService/RestoreUrlService.php index 434fc278..63f5201c 100644 --- a/src/Storefront/Checkout/Cart/RestoreUrlService/RestoreUrlService.php +++ b/src/Storefront/Checkout/Cart/RestoreUrlService/RestoreUrlService.php @@ -28,7 +28,7 @@ class RestoreUrlService implements RestoreUrlServiceInterface public function __construct( EntityRepository $mappingRepository, UrlGeneratorInterface $urlGenerator, - RequestStack $requestStack + RequestStack $requestStack, ) { $this->mappingRepository = $mappingRepository; $this->urlGenerator = $urlGenerator; @@ -39,7 +39,7 @@ public function getCurrentRestoreUrl(SalesChannelContext $context): string { $current = $this->fetchFromDb($context->getToken(), $context->getContext()); return $this->generate( - $current ? $current->getId() : $this->createNew($context->getToken(), $context->getContext()) + $current ? $current->getId() : $this->createNew($context->getToken(), $context->getContext()), ); } @@ -48,7 +48,7 @@ protected function fetchFromDb(string $token, Context $context): ?CheckoutMappin $criteria = new Criteria(); $criteria->addFilter( new EqualsFilter('reference', $token), - new EqualsFilter('mappingTable', CheckoutMappingDefinition::CART_TABLE) + new EqualsFilter('mappingTable', CheckoutMappingDefinition::CART_TABLE), ); $criteria->addSorting(new FieldSorting('createdAt', FieldSorting::DESCENDING)); return $this->mappingRepository->search($criteria, $context)->first(); @@ -58,13 +58,13 @@ private function generate(string $id): string { // TODO: Change routing name return $this->requestStack->getCurrentRequest()->attributes->get( - RequestTransformer::STOREFRONT_URL + RequestTransformer::STOREFRONT_URL, ) . $this->urlGenerator->generate( 'frontend.cart.nosto-restore-cart', [ 'mappingId' => $id, ], - UrlGeneratorInterface::ABSOLUTE_PATH + UrlGeneratorInterface::ABSOLUTE_PATH, ); } diff --git a/src/Storefront/Checkout/Cart/RestorerService/RestorerService.php b/src/Storefront/Checkout/Cart/RestorerService/RestorerService.php index ad724321..f51d6d35 100644 --- a/src/Storefront/Checkout/Cart/RestorerService/RestorerService.php +++ b/src/Storefront/Checkout/Cart/RestorerService/RestorerService.php @@ -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 { @@ -38,7 +39,7 @@ public function __construct( CartRuleLoader $cartRuleLoader, CartService $cartService, OrderConverter $orderConverter, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->mappingRepository = $mappingRepository; $this->orderRepository = $orderRepository; @@ -57,12 +58,12 @@ public function restore(string $mappingId, SalesChannelContext $context): void } $mapping->getMappingTable() === CheckoutMappingDefinition::CART_TABLE ? $this->restoreCart( $mapping->getReference(), - $context + $context, ) : $this->restoreOrder($mapping->getReference(), $context); } catch (Throwable $throwable) { $this->logger->error( 'Unable to restore the cart', - ContextHelper::createContextFromException($throwable) + ContextHelper::createContextFromException($throwable), ); } } diff --git a/src/Struct/FiltersExtension.php b/src/Struct/FiltersExtension.php index 9c543092..d9ea987e 100644 --- a/src/Struct/FiltersExtension.php +++ b/src/Struct/FiltersExtension.php @@ -13,7 +13,7 @@ class FiltersExtension extends Struct * @param Filter[] $filters */ public function __construct( - private array $filters = [] + private array $filters = [], ) { } diff --git a/src/Struct/IdToFieldMapping.php b/src/Struct/IdToFieldMapping.php index aecd0880..aeaffacd 100644 --- a/src/Struct/IdToFieldMapping.php +++ b/src/Struct/IdToFieldMapping.php @@ -12,7 +12,7 @@ class IdToFieldMapping extends Struct * @param array $map */ public function __construct( - private array $map = [] + private array $map = [], ) { } diff --git a/src/Struct/PageInformation.php b/src/Struct/PageInformation.php index 1ef9fbfe..17b52fc1 100644 --- a/src/Struct/PageInformation.php +++ b/src/Struct/PageInformation.php @@ -10,7 +10,7 @@ class PageInformation extends Struct { public function __construct( private readonly bool $isSearchPage, - private readonly bool $isNavigationPage + private readonly bool $isNavigationPage, ) { } diff --git a/src/Struct/Pagination.php b/src/Struct/Pagination.php index dd78a7d2..7513c67d 100644 --- a/src/Struct/Pagination.php +++ b/src/Struct/Pagination.php @@ -13,7 +13,7 @@ class Pagination extends Struct public function __construct( private ?int $limit, private ?int $offset, - private readonly ?int $total + private readonly ?int $total, ) { $this->limit = $limit ?? self::DEFAULT_LIMIT; $this->offset = $offset ?? 0; diff --git a/src/Struct/Redirect.php b/src/Struct/Redirect.php index 244abb5a..478334db 100644 --- a/src/Struct/Redirect.php +++ b/src/Struct/Redirect.php @@ -9,7 +9,7 @@ class Redirect extends Struct { public function __construct( - protected readonly string $link + protected readonly string $link, ) { } diff --git a/src/Subscriber/FrontendSubscriber.php b/src/Subscriber/FrontendSubscriber.php index 0866ec14..10acadee 100644 --- a/src/Subscriber/FrontendSubscriber.php +++ b/src/Subscriber/FrontendSubscriber.php @@ -9,14 +9,13 @@ use Nosto\NostoIntegration\Struct\NostoService; use Nosto\NostoIntegration\Struct\PageInformation; use Nosto\NostoIntegration\Utils\SearchHelper; -use Psr\Cache\InvalidArgumentException; use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class FrontendSubscriber implements EventSubscriberInterface { public function __construct( - private readonly NostoConfigService $nostoConfigService + private readonly NostoConfigService $nostoConfigService, ) { } @@ -30,9 +29,6 @@ public static function getSubscribedEvents(): array ]; } - /** - * @throws InvalidArgumentException - */ public function onHeaderLoaded(HeaderPageletLoadedEvent $event): void { $config = $this->nostoConfigService->getConfigWithInheritance( diff --git a/src/Traits/SearchResultHelper.php b/src/Traits/SearchResultHelper.php index 495e549d..2d66e02a 100644 --- a/src/Traits/SearchResultHelper.php +++ b/src/Traits/SearchResultHelper.php @@ -35,7 +35,7 @@ protected function createEmptySearchResult(Criteria $criteria, Context $context) protected function fetchProducts( Criteria $criteria, SalesChannelContext $salesChannelContext, - ?string $query = null + ?string $query = null, ): EntitySearchResult { if ($query !== null && count($criteria->getIds()) === 1) { $this->modifyCriteriaFromQuery($query, $criteria, $salesChannelContext); @@ -43,7 +43,7 @@ protected function fetchProducts( $result = $this->salesChannelProductRepository->search( $this->cleanDatabaseCriteria($criteria), - $salesChannelContext + $salesChannelContext, ); return $this->fixResultOrder($result, $criteria); @@ -132,7 +132,7 @@ public function getOffset(Request $request, ?int $limit = null): float|int private function modifyCriteriaFromQuery( string $query, Criteria $criteria, - SalesChannelContext $salesChannelContext + SalesChannelContext $salesChannelContext, ): void { $productCriteria = new Criteria(); $productCriteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_OR, [ diff --git a/src/Twig/Extension/CustomerExtension.php b/src/Twig/Extension/CustomerExtension.php index 1f3eb796..eb203478 100644 --- a/src/Twig/Extension/CustomerExtension.php +++ b/src/Twig/Extension/CustomerExtension.php @@ -4,10 +4,12 @@ namespace Nosto\NostoIntegration\Twig\Extension; +use Nosto\Model\Customer; use Nosto\NostoIntegration\Model\Nosto\Entity\Customer\BuilderInterface; use Nosto\NostoIntegration\Storefront\Checkout\Cart\RestoreUrlService\RestoreUrlService; use Shopware\Core\Checkout\Customer\CustomerEntity; use Shopware\Core\Framework\Context; +use Shopware\Core\System\SalesChannel\SalesChannelContext; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -19,7 +21,7 @@ class CustomerExtension extends AbstractExtension public function __construct( BuilderInterface $builder, - RestoreUrlService $restoreUrlService + RestoreUrlService $restoreUrlService, ) { $this->builder = $builder; $this->restoreUrlService = $restoreUrlService; @@ -33,15 +35,13 @@ public function getFunctions(): array ]; } - public function getNostoCustomer(CustomerEntity $customer, Context $context) + public function getNostoCustomer(CustomerEntity $customer, Context $context): Customer { return $this->builder->build($customer, $context); } - public function getRestoreCartLink(\Shopware\Core\System\SalesChannel\SalesChannelContext $context): string + public function getRestoreCartLink(SalesChannelContext $context): string { - $url = $this->restoreUrlService->getCurrentRestoreUrl($context); - - return $url; + return $this->restoreUrlService->getCurrentRestoreUrl($context); } } diff --git a/src/Twig/Extension/NostoExtension.php b/src/Twig/Extension/NostoExtension.php index cec60dd5..d0ad6b39 100644 --- a/src/Twig/Extension/NostoExtension.php +++ b/src/Twig/Extension/NostoExtension.php @@ -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; @@ -27,7 +28,7 @@ class NostoExtension extends AbstractExtension public function __construct( ProductProviderInterface $productProvider, LoggerInterface $logger, - SalesChannelRepository $salesChannelProductRepository + SalesChannelRepository $salesChannelProductRepository, ) { $this->productProvider = $productProvider; $this->logger = $logger; @@ -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; } diff --git a/src/Utils/Lifecycle.php b/src/Utils/Lifecycle.php index bb6b762b..0e7b5caa 100644 --- a/src/Utils/Lifecycle.php +++ b/src/Utils/Lifecycle.php @@ -19,7 +19,6 @@ use Shopware\Core\Framework\Plugin\Context\UninstallContext; use Shopware\Core\Framework\Plugin\Context\UpdateContext; use Symfony\Component\DependencyInjection\ContainerInterface; -use function version_compare; class Lifecycle { @@ -37,7 +36,7 @@ class Lifecycle public function __construct( ContainerInterface $container, - bool $hasOtherSchedulerDependency + bool $hasOtherSchedulerDependency, ) { /** @var Connection $connection */ $connection = $container->get(Connection::class); @@ -51,12 +50,12 @@ public function __construct( $this->salesChannelRepository = $this->container->get('sales_channel.repository'); } - public function install(InstallContext $installContext) + public function install(InstallContext $installContext): void { $this->importSorting($installContext->getContext()); } - public function update(UpdateContext $updateContext) + public function update(UpdateContext $updateContext): void { $this->importSorting($updateContext->getContext()); if (version_compare($updateContext->getCurrentPluginVersion(), '1.0.10', '<')) { @@ -64,17 +63,17 @@ public function update(UpdateContext $updateContext) } } - public function deactivate(DeactivateContext $deactivateContext) + public function deactivate(DeactivateContext $deactivateContext): void { $this->removeSorting($deactivateContext->getContext()); } - public function activate(ActivateContext $activateContext) + public function activate(ActivateContext $activateContext): void { $this->importSorting($activateContext->getContext()); } - public function removeSorting(Context $context) + public function removeSorting(Context $context): void { $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('key', MerchandisingSearchApi::MERCHANDISING_SORTING_KEY)); @@ -87,7 +86,7 @@ public function removeSorting(Context $context) ]], $context); } - public function importSorting(Context $context) + public function importSorting(Context $context): void { $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('key', MerchandisingSearchApi::MERCHANDISING_SORTING_KEY)); @@ -136,7 +135,7 @@ public function uninstall(UninstallContext $context): void 'DELETE FROM migration WHERE class LIKE :class', [ 'class' => $schedulerMigrationClassWildcard, - ] + ], ); } @@ -145,7 +144,7 @@ public function uninstall(UninstallContext $context): void } } - public function removePendingJobs() + public function removePendingJobs(): void { $this->connection->executeStatement( "DELETE from `nosto_scheduler_job` WHERE `type` LIKE :prefix", @@ -158,7 +157,9 @@ public function removePendingJobs() public function removeOldTags(Context $context): void { $channelCriteria = new Criteria(); - $channelCriteria->addFilter(new EqualsAnyFilter('typeId', [Defaults::SALES_CHANNEL_TYPE_STOREFRONT, Defaults::SALES_CHANNEL_TYPE_API])); + $channelCriteria->addFilter( + new EqualsAnyFilter('typeId', [Defaults::SALES_CHANNEL_TYPE_STOREFRONT, Defaults::SALES_CHANNEL_TYPE_API]), + ); $channelIds = $this->salesChannelRepository->searchIds($channelCriteria, $context); foreach ($channelIds->getIds() as $channelId) { diff --git a/src/Utils/Logger/ContextHelper.php b/src/Utils/Logger/ContextHelper.php index 37beb6f4..5d682115 100644 --- a/src/Utils/Logger/ContextHelper.php +++ b/src/Utils/Logger/ContextHelper.php @@ -4,12 +4,14 @@ namespace Nosto\NostoIntegration\Utils\Logger; +use Generator; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; +use Throwable; class ContextHelper { - public static function createContextFromException(\Throwable $exception): array + public static function createContextFromException(Throwable $exception): array { $context = [ 'exception' => $exception, @@ -31,7 +33,7 @@ public static function convertLoggableContextToPlainRepresentation(array $contex } return $context; - } catch (\Throwable $throwable) { + } catch (Throwable $throwable) { $context['Exception during context conversion'] = $throwable->getMessage(); return $context; @@ -46,7 +48,7 @@ public static function convertLoggableContextToPlainRepresentation(array $contex * * @return int|float|string|array */ - public static function convertVariableToSerializableRepresentation($value, int $deep = 10) + public static function convertVariableToSerializableRepresentation(mixed $value, int $deep = 10): mixed { if ($deep < 1) { return '{maximum nesting level reached}'; @@ -60,7 +62,7 @@ public static function convertVariableToSerializableRepresentation($value, int $ return self::convertResponseToSerializable($value); } - if ($value instanceof \Generator) { + if ($value instanceof Generator) { return '{Generator}'; } if (is_iterable($value)) { diff --git a/src/Utils/MigrationHelper.php b/src/Utils/MigrationHelper.php index 6b7214ca..977aa974 100644 --- a/src/Utils/MigrationHelper.php +++ b/src/Utils/MigrationHelper.php @@ -26,8 +26,8 @@ public function getMigrationCollection(Bundle $bundleInstance): MigrationCollect $bundleInstance->getPath() . str_replace( $bundleInstance->getNamespace(), '', - $bundleInstance->getMigrationNamespace() - ) + $bundleInstance->getMigrationNamespace(), + ), ); if (!is_dir($migrationPath)) { diff --git a/src/Utils/SearchHelper.php b/src/Utils/SearchHelper.php index 94abd593..0a26f626 100644 --- a/src/Utils/SearchHelper.php +++ b/src/Utils/SearchHelper.php @@ -14,7 +14,7 @@ class SearchHelper public static function shouldHandleRequest( SalesChannelContext $context, ConfigProvider $configProvider, - bool $isNavigationPage = false + bool $isNavigationPage = false, ): bool { /** @var NostoService $nostoService */ $nostoService = $context->getContext()->getExtension('nostoService');