diff --git a/src/Command/QueuedIndexDataCommand.php b/src/Command/QueuedIndexDataCommand.php index ca92bed..b0b9f70 100644 --- a/src/Command/QueuedIndexDataCommand.php +++ b/src/Command/QueuedIndexDataCommand.php @@ -1,5 +1,16 @@ hasExtension('core_shop_seo'); foreach ($configs as $config) { - $thirdPartyConfig = $config['meta_data_configuration']['meta_data_provider']['third_party'] ?? null; if ($thirdPartyConfig === null) { @@ -81,7 +91,6 @@ public function prepend(ContainerBuilder $container): void } $container->setParameter('seo.third_party.enabled', array_keys($enabledThirdPartyConfigs)); - } private function validateConfiguration(array $config): void diff --git a/src/EventListener/Admin/AssetListener.php b/src/EventListener/Admin/AssetListener.php index 4dda5ca..b05c5d1 100644 --- a/src/EventListener/Admin/AssetListener.php +++ b/src/EventListener/Admin/AssetListener.php @@ -1,5 +1,16 @@ getArgument('list'); foreach ($list['data'] as $listIndex => $item) { - if ($item['type'] !== 'page') { continue; } @@ -98,6 +108,5 @@ public function updateData(DocumentEvent $event): void 'title_description', $integratorData ); - } } diff --git a/src/EventListener/Admin/XliffListener.php b/src/EventListener/Admin/XliffListener.php index 168a766..a3972a1 100644 --- a/src/EventListener/Admin/XliffListener.php +++ b/src/EventListener/Admin/XliffListener.php @@ -1,5 +1,16 @@ getAttributes() as $attribute) { - if ($attribute->getType() !== self::XLIFF_TYPE) { continue; } diff --git a/src/EventListener/AutoMetaDataAttachListener.php b/src/EventListener/AutoMetaDataAttachListener.php index a817c88..7dc9deb 100644 --- a/src/EventListener/AutoMetaDataAttachListener.php +++ b/src/EventListener/AutoMetaDataAttachListener.php @@ -1,15 +1,26 @@ cleanEmptyLocaleRows($data, $dataIdentifier); // nothing to merge @@ -56,12 +65,12 @@ public function mergeLocaleAwareArrays( } foreach ($cleanedRows as $row) { - $previousRowIndex = array_search($row[$rowIdentifier], array_column($previousData, $rowIdentifier), true); if ($previousRowIndex === false) { $newData[$newDataIndex] = $row; $newDataIndex++; + continue; } @@ -74,6 +83,7 @@ public function mergeLocaleAwareArrays( if (!is_array($currentValue) || $this->isAssocArray($currentValue)) { $newData[$dataIndex] = $row; $newDataIndex++; + continue; } @@ -112,24 +122,20 @@ public function rebuildLocaleValueRow(array $values, array $rebuildRow, bool $me $cleanedRebuildRow = array_values($cleanedRebuildRow); foreach ($values as $currentRow) { - $locale = $currentRow['locale']; $value = $currentRow['value']; $index = array_search($locale, array_column($cleanedRebuildRow, 'locale'), true); if ($index !== false) { - if ($value === null) { unset($cleanedRebuildRow[$index]); } else { $cleanedRebuildRow[$index] = $currentRow; } - } elseif ($value !== null) { $cleanedRebuildRow[] = $currentRow; } - } return array_values($cleanedRebuildRow); @@ -139,7 +145,6 @@ public function cleanEmptyLocaleRows(array $field, string $dataIdentifier = 'val { $cleanData = []; foreach ($field as $row) { - if ($row[$dataIdentifier] === null) { continue; } diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 062b952..ba2f9b5 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -1,5 +1,16 @@ getElementData($elementType, $elementId, true); foreach ($data as $element) { - if ($element->getReleaseType() === ElementMetaDataInterface::RELEASE_TYPE_DRAFT) { $isDraft = true; } @@ -87,7 +97,6 @@ public function getElementDataForXliffExport(string $elementType, int $elementId $data = $this->getElementData($elementType, $elementId); foreach ($data as $element) { - $metaDataIntegrator = $this->metaDataIntegratorRegistry->get($element->getIntegrator()); if (!$metaDataIntegrator instanceof XliffAwareIntegratorInterface) { continue; @@ -109,7 +118,6 @@ public function saveElementDataFromXliffImport(string $elementType, int $element $integratorValues = []; foreach ($rawData as $integrator => $integratorRawData) { - if (!is_array($integratorRawData)) { continue; } @@ -136,7 +144,6 @@ public function saveElementData( bool $merge = false, string $releaseType = ElementMetaDataInterface::RELEASE_TYPE_PUBLIC ): void { - $elementMetaData = $this->determinateElementMetaEntity($elementType, $elementId, $integratorName, $releaseType); if (!$elementMetaData instanceof ElementMetaDataInterface) { @@ -152,9 +159,7 @@ public function saveElementData( // remove empty meta data if ($sanitizedData === null) { - if ($releaseType === ElementMetaDataInterface::RELEASE_TYPE_DRAFT) { - // if draft, we still persist an empty element // to determinate reset when publish state is incoming @@ -318,11 +323,9 @@ private function determinateElementMetaEntity( string $integratorName, string $releaseType = ElementMetaDataInterface::RELEASE_TYPE_PUBLIC ): ?ElementMetaDataInterface { - $hasDraft = $this->elementMetaDataExistsWithReleaseType($elementType, $elementId, ElementMetaDataInterface::RELEASE_TYPE_DRAFT); if ($releaseType === ElementMetaDataInterface::RELEASE_TYPE_PUBLIC && $hasDraft === true) { - // delete draft $this->deleteElementData($elementType, $elementId, ElementMetaDataInterface::RELEASE_TYPE_DRAFT); @@ -355,5 +358,4 @@ private function elementMetaDataExistsWithReleaseType(string $elementType, int $ ->getQuery() ->getSingleScalarResult() > 0; } - } diff --git a/src/Manager/ElementMetaDataManagerInterface.php b/src/Manager/ElementMetaDataManagerInterface.php index 1127c3a..07bbf88 100644 --- a/src/Manager/ElementMetaDataManagerInterface.php +++ b/src/Manager/ElementMetaDataManagerInterface.php @@ -1,5 +1,16 @@ getImage())) { $path = $element->getImage()->getThumbnail('coreshop_seo'); - $ogImage = (str_starts_with('http', $path) ? '' : Tool::getHostUrl()).$path; + $ogImage = (str_starts_with('http', $path) ? '' : Tool::getHostUrl()) . $path; $seoMetadata->addExtraProperty('og:image', $ogImage); } } diff --git a/src/MetaData/Extractor/ThirdParty/CoreShop/TitleDescriptionExtractor.php b/src/MetaData/Extractor/ThirdParty/CoreShop/TitleDescriptionExtractor.php index 96c6bbc..b7c7625 100644 --- a/src/MetaData/Extractor/ThirdParty/CoreShop/TitleDescriptionExtractor.php +++ b/src/MetaData/Extractor/ThirdParty/CoreShop/TitleDescriptionExtractor.php @@ -1,5 +1,16 @@ configuration['properties'], 0), true); @@ -143,7 +153,6 @@ public function updateMetaData($element, array $data, ?string $locale, SeoMetaDa $addedItems = 0; foreach ($data as $ogItem) { - if (empty($ogItem['value']) || empty($ogItem['property'])) { continue; } @@ -163,7 +172,6 @@ public function updateMetaData($element, array $data, ?string $locale, SeoMetaDa $addedItems++; $seoMetadata->addExtraProperty($propertyName, $value); - } if ($addedItems > 0 && null !== $elementUrl = $this->urlGenerator->generate($element)) { diff --git a/src/MetaData/Integrator/SchemaIntegrator.php b/src/MetaData/Integrator/SchemaIntegrator.php index 38c9372..adf658b 100644 --- a/src/MetaData/Integrator/SchemaIntegrator.php +++ b/src/MetaData/Integrator/SchemaIntegrator.php @@ -1,5 +1,16 @@ configuration['properties'], 0), true); @@ -133,7 +143,6 @@ public function updateMetaData(mixed $element, array $data, ?string $locale, Seo } foreach ($data as $twitterItem) { - if (empty($twitterItem['value']) || empty($twitterItem['name'])) { continue; } diff --git a/src/MetaData/Integrator/XliffAwareIntegratorInterface.php b/src/MetaData/Integrator/XliffAwareIntegratorInterface.php index 40e6e12..6f0eb99 100644 --- a/src/MetaData/Integrator/XliffAwareIntegratorInterface.php +++ b/src/MetaData/Integrator/XliffAwareIntegratorInterface.php @@ -1,5 +1,16 @@ getCode(); foreach ($response->getErrors() as $error) { - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ $formattedMessages[] = $error['message']; } @@ -182,12 +193,12 @@ protected function buildSuccessResponse(PublishUrlNotificationResponse $response $latestUpdateInfo = $notificationMetaData->getLatestUpdate(); $latestRemoveInfo = $notificationMetaData->getLatestRemove(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ if ($latestUpdateInfo instanceof UrlNotification) { $formattedMessageMeta[] = sprintf('Latest Update Info: %s %s', $latestUpdateInfo->getType(), $latestUpdateInfo->getNotifyTime()); } - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ if ($latestRemoveInfo instanceof UrlNotification) { $formattedMessageMeta[] = sprintf('Latest Remove Info: %s %s', $latestRemoveInfo->getType(), $latestRemoveInfo->getNotifyTime()); } diff --git a/src/Worker/IndexWorkerInterface.php b/src/Worker/IndexWorkerInterface.php index a021cf0..e79e6ad 100644 --- a/src/Worker/IndexWorkerInterface.php +++ b/src/Worker/IndexWorkerInterface.php @@ -1,5 +1,16 @@