diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e3633de7..667c25b2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,11 +68,16 @@ jobs: if: ${{ always() && steps.install.conclusion == 'success' }} run: | composer cgl:ci - - id: phpstan + - id: phpstan-v12 name: PHPStan - if: ${{ always() && steps.install.conclusion == 'success' }} + if: ${{ always() && steps.install.conclusion == 'success' && matrix.typo3 == '^12' }} + run: | + composer phpstan-v12 -- --error-format=github + - id: phpstan-v13 + name: PHPStan + if: ${{ always() && steps.install.conclusion == 'success' && matrix.typo3 != '^12' }} run: | - composer phpstan -- --error-format=github + composer phpstan-v13 -- --error-format=github - id: tests_unit name: Unit Tests if: ${{ always() && steps.install.conclusion == 'success' && matrix.php == '8.3' }} diff --git a/Build/phpstan-baseline-v12.neon b/Build/phpstan-baseline-v12.neon new file mode 100644 index 000000000..f953d7e27 --- /dev/null +++ b/Build/phpstan-baseline-v12.neon @@ -0,0 +1,26 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Package\\\\AbstractServiceProvider\\:\\:configureSetCollector\\(\\)\\.$#" + count: 1 + path: ../Classes/ServiceProvider.php + + - + message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetCollector not found\\.$#" + count: 1 + path: ../Classes/ServiceProvider.php + + - + message: "#^Instantiated class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetDefinition not found\\.$#" + count: 1 + path: ../Classes/ServiceProvider.php + + - + message: "#^Method BK2K\\\\BootstrapPackage\\\\ServiceProvider\\:\\:configureSetCollector\\(\\) has invalid return type TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetCollector\\.$#" + count: 1 + path: ../Classes/ServiceProvider.php + + - + message: "#^Parameter \\$setCollector of method BK2K\\\\BootstrapPackage\\\\ServiceProvider\\:\\:configureSetCollector\\(\\) has invalid type TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetCollector\\.$#" + count: 1 + path: ../Classes/ServiceProvider.php diff --git a/Build/phpstan-v12.neon b/Build/phpstan-v12.neon new file mode 100644 index 000000000..7ac736cd3 --- /dev/null +++ b/Build/phpstan-v12.neon @@ -0,0 +1,3 @@ +includes: + - %currentWorkingDirectory%/Build/phpstan.neon + - %currentWorkingDirectory%/Build/phpstan-baseline-v12.neon diff --git a/Build/phpstan-v13.neon b/Build/phpstan-v13.neon new file mode 100644 index 000000000..155c33649 --- /dev/null +++ b/Build/phpstan-v13.neon @@ -0,0 +1,3 @@ +includes: + - %currentWorkingDirectory%/Build/phpstan.neon + - %currentWorkingDirectory%/Build/phpstan-baseline-v13.neon diff --git a/Build/phpstan.neon b/Build/phpstan.neon index f425b9b4a..878fd19b7 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -3,7 +3,6 @@ includes: - %currentWorkingDirectory%/.build/vendor/phpstan/phpstan-strict-rules/rules.neon - %currentWorkingDirectory%/.build/vendor/phpstan/phpstan-deprecation-rules/rules.neon - %currentWorkingDirectory%/.build/vendor/friendsoftypo3/phpstan-typo3/extension.neon - - %currentWorkingDirectory%/Build/phpstan-baseline-v13.neon parameters: level: 8 diff --git a/Classes/ServiceProvider.php b/Classes/ServiceProvider.php new file mode 100644 index 000000000..caeba0134 --- /dev/null +++ b/Classes/ServiceProvider.php @@ -0,0 +1,84 @@ +getMajorVersion() <= 12) { + return parent::getExtensions(); + } + + return [ + SetCollector::class => [ static::class, 'configureSetCollector' ], + ] + parent::getExtensions(); + } + + public static function configureSetCollector(ContainerInterface $container, SetCollector $setCollector, ?string $path = null): SetCollector + { + $setCollector = parent::configureSetCollector($container, $setCollector, $path); + $availableSets = $setCollector->getSetDefinitions(); + $bpFullSet = $availableSets['bootstrap-package/full'] ?? null; + if ($bpFullSet === null) { + return $setCollector; + } + + $optionalDependencies = []; + if (isset($availableSets['typo3/form'])) { + $optionalDependencies[] = 'bootstrap-package/ext-form'; + } + if (isset($availableSets['typo3/seo-sitemap'])) { + $optionalDependencies[] = 'bootstrap-package/ext-seo'; + } + if (isset($availableSets['typo3/indexed-search'])) { + $optionalDependencies[] = 'bootstrap-package/ext-indexed-search'; + } + if ($container->get(PackageManager::class)->isPackageActive('container')) { + $optionalDependencies[] = 'bootstrap-package/ext-container'; + } + + $setCollector->add( + new SetDefinition(...[ + ...$bpFullSet->toArray(), + 'dependencies' => [ + ...$bpFullSet->dependencies, + ...$optionalDependencies, + ], + ]) + ); + return $setCollector; + } +} diff --git a/Configuration/Sets/ExtContainer/config.yaml b/Configuration/Sets/ExtContainer/config.yaml new file mode 100644 index 000000000..ecc037a9d --- /dev/null +++ b/Configuration/Sets/ExtContainer/config.yaml @@ -0,0 +1,2 @@ +name: bootstrap-package/ext-container +label: 'Bootstrap Package: EXT:container integration' diff --git a/Configuration/Sets/ExtContainer/setup.typoscript b/Configuration/Sets/ExtContainer/setup.typoscript new file mode 100644 index 000000000..d369d2b06 --- /dev/null +++ b/Configuration/Sets/ExtContainer/setup.typoscript @@ -0,0 +1 @@ +@import 'EXT:bootstrap_package/Configuration/TypoScript/Extension/Container/setup.typoscript' diff --git a/Configuration/Sets/ExtForm/config.yaml b/Configuration/Sets/ExtForm/config.yaml new file mode 100644 index 000000000..dd84d54d5 --- /dev/null +++ b/Configuration/Sets/ExtForm/config.yaml @@ -0,0 +1,4 @@ +name: bootstrap-package/ext-form +label: 'Bootstrap Package: EXT:form integration' +dependencies: + - typo3/form diff --git a/Configuration/Sets/ExtIndexedSearch/config.yaml b/Configuration/Sets/ExtIndexedSearch/config.yaml new file mode 100644 index 000000000..a650b183a --- /dev/null +++ b/Configuration/Sets/ExtIndexedSearch/config.yaml @@ -0,0 +1,4 @@ +name: bootstrap-package/ext-indexed-search +label: 'Bootstrap Package: EXT:indexed_search integration' +dependencies: + - typo3/indexed-search diff --git a/Configuration/Sets/ExtIndexedSearch/setup.typoscript b/Configuration/Sets/ExtIndexedSearch/setup.typoscript new file mode 100644 index 000000000..69b0f36ef --- /dev/null +++ b/Configuration/Sets/ExtIndexedSearch/setup.typoscript @@ -0,0 +1,16 @@ +plugin.tx_indexedsearch { + view { + templateRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Templates/IndexedSearch/ + 21 = {$plugin.bootstrap_package.view.templateRootPath}IndexedSearch/ + } + partialRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Partials/IndexedSearch/ + 21 = {$plugin.bootstrap_package.view.partialRootPath}IndexedSearch/ + } + layoutRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Layouts/IndexedSearch/ + 21 = {$plugin.bootstrap_package.view.layoutRootPath}IndexedSearch/ + } + } +} diff --git a/Configuration/Sets/ExtSeo/config.yaml b/Configuration/Sets/ExtSeo/config.yaml new file mode 100644 index 000000000..963c936cd --- /dev/null +++ b/Configuration/Sets/ExtSeo/config.yaml @@ -0,0 +1,4 @@ +name: bootstrap-package/ext-seo +label: 'Bootstrap Package: EXT:seo integration' +dependencies: + - typo3/seo-sitemap diff --git a/Configuration/Sets/ExtSeo/setup.typoscript b/Configuration/Sets/ExtSeo/setup.typoscript new file mode 100644 index 000000000..ebdfcd619 --- /dev/null +++ b/Configuration/Sets/ExtSeo/setup.typoscript @@ -0,0 +1,16 @@ +plugin.tx_seo { + view { + templateRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Templates/Seo/ + 21 = {$plugin.bootstrap_package.view.templateRootPath}Seo/ + } + partialRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Partials/Seo/ + 21 = {$plugin.bootstrap_package.view.partialRootPath}Seo/ + } + layoutRootPaths { + 20 = EXT:bootstrap_package/Resources/Private/Layouts/Seo/ + 21 = {$plugin.bootstrap_package.view.layoutRootPath}Seo/ + } + } +} diff --git a/Configuration/Sets/Full/config.yaml b/Configuration/Sets/Full/config.yaml index 2e1d0ecc3..afbbdbda5 100644 --- a/Configuration/Sets/Full/config.yaml +++ b/Configuration/Sets/Full/config.yaml @@ -7,3 +7,8 @@ dependencies: - bootstrap-package/google-font - bootstrap-package/google-tag-manager - bootstrap-package/skiplink + # optional dependencies added by ServiceProvider + # - bootstrap-package/ext-form + # - bootstrap-package/ext-indexed-search + # - bootstrap-package/ext-seo-sitemap + # - bootstrap-package/ext-container diff --git a/Configuration/Sets/Full/setup.typoscript b/Configuration/Sets/Full/setup.typoscript index 0d5bc7e76..4d3e364fd 100644 --- a/Configuration/Sets/Full/setup.typoscript +++ b/Configuration/Sets/Full/setup.typoscript @@ -1,6 +1,3 @@ -# DEPENDENCIES -@import 'EXT:bootstrap_package/Configuration/TypoScript/Extension/setup.typoscript' - # HELPER @import 'EXT:bootstrap_package/Configuration/TypoScript/Helper/Block.typoscript' @import 'EXT:bootstrap_package/Configuration/TypoScript/Helper/PageClass.typoscript' diff --git a/composer.json b/composer.json index dec5c108f..2d55c4284 100644 --- a/composer.json +++ b/composer.json @@ -80,6 +80,9 @@ }, "typo3/cms": { "extension-key": "bootstrap_package", + "Package": { + "serviceProvider": "BK2K\\BootstrapPackage\\ServiceProvider" + }, "web-dir": ".build/public" } }, @@ -115,8 +118,11 @@ "changelog": [ "extension-helper changelog:create" ], - "phpstan": [ - "phpstan analyze --configuration Build/phpstan.neon" + "phpstan-v12": [ + "phpstan analyze --configuration Build/phpstan-v12.neon" + ], + "phpstan-v13": [ + "phpstan analyze --configuration Build/phpstan-v13.neon" ], "phpstan:baseline": [ "phpstan analyze --configuration Build/phpstan.neon --generate-baseline Build/phpstan-baseline.neon"