Skip to content

Commit

Permalink
[WIP][TASK] Make sets conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
bnf committed Oct 17, 2024
1 parent a04a042 commit c6234ac
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 3 deletions.
79 changes: 79 additions & 0 deletions Classes/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php declare(strict_types=1);

/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace BK2K\BootstrapPackage;

use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Package\AbstractServiceProvider;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Site\Set\SetCollector;
use TYPO3\CMS\Core\Site\Set\SetDefinition;

/**
* @internal
*/
class ServiceProvider extends AbstractServiceProvider
{
protected static function getPackagePath(): string
{
return __DIR__ . '/../';
}

protected static function getPackageName(): string
{
return 'typo3/cms-core';
}

public function getFactories(): array
{
return [];
}

public function getExtensions(): array
{
return [
SetCollector::class => [ static::class, 'configureSetCollector' ],

Check failure on line 41 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.2)

Class TYPO3\CMS\Core\Site\Set\SetCollector not found.

Check failure on line 41 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.3)

Class TYPO3\CMS\Core\Site\Set\SetCollector not found.

Check failure on line 41 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.1)

Class TYPO3\CMS\Core\Site\Set\SetCollector not found.
] + parent::getExtensions();
}

public static function configureSetCollector(ContainerInterface $container, SetCollector $setCollector, ?string $path = null): SetCollector

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.2)

Method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid return type TYPO3\CMS\Core\Site\Set\SetCollector.

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.2)

Parameter $setCollector of method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid type TYPO3\CMS\Core\Site\Set\SetCollector.

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.3)

Method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid return type TYPO3\CMS\Core\Site\Set\SetCollector.

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.3)

Parameter $setCollector of method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid type TYPO3\CMS\Core\Site\Set\SetCollector.

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.1)

Method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid return type TYPO3\CMS\Core\Site\Set\SetCollector.

Check failure on line 45 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.1)

Parameter $setCollector of method BK2K\BootstrapPackage\ServiceProvider::configureSetCollector() has invalid type TYPO3\CMS\Core\Site\Set\SetCollector.
{
$setCollector = parent::configureSetCollector($container, $setCollector, $path);

Check failure on line 47 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.2)

Call to an undefined static method TYPO3\CMS\Core\Package\AbstractServiceProvider::configureSetCollector().

Check failure on line 47 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.3)

Call to an undefined static method TYPO3\CMS\Core\Package\AbstractServiceProvider::configureSetCollector().

Check failure on line 47 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.1)

Call to an undefined static method TYPO3\CMS\Core\Package\AbstractServiceProvider::configureSetCollector().
$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(...[

Check failure on line 69 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.2)

Instantiated class TYPO3\CMS\Core\Site\Set\SetDefinition not found.

Check failure on line 69 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.3)

Instantiated class TYPO3\CMS\Core\Site\Set\SetDefinition not found.

Check failure on line 69 in Classes/ServiceProvider.php

View workflow job for this annotation

GitHub Actions / Build PHP (^12, 8.1)

Instantiated class TYPO3\CMS\Core\Site\Set\SetDefinition not found.
...$bpFullSet->toArray(),
'dependencies' => [
...$bpFullSet->dependencies,
...$optionalDependencies,
],
])
);
return $setCollector;
}
}
2 changes: 2 additions & 0 deletions Configuration/Sets/ExtContainer/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: bootstrap-package/ext-container
label: 'Bootstrap Package: EXT:container integration'
1 change: 1 addition & 0 deletions Configuration/Sets/ExtContainer/setup.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'EXT:bootstrap_package/Configuration/TypoScript/Extension/Container/setup.typoscript'
4 changes: 4 additions & 0 deletions Configuration/Sets/ExtForm/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: bootstrap-package/ext-form
label: 'Bootstrap Package: EXT:form integration'
dependencies:
- typo3/form
4 changes: 4 additions & 0 deletions Configuration/Sets/ExtIndexedSearch/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: bootstrap-package/ext-indexed-search
label: 'Bootstrap Package: EXT:indexed_search integration'
dependencies:
- typo3/indexed-search
16 changes: 16 additions & 0 deletions Configuration/Sets/ExtIndexedSearch/setup.typoscript
Original file line number Diff line number Diff line change
@@ -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/
}
}
}
4 changes: 4 additions & 0 deletions Configuration/Sets/ExtSeo/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: bootstrap-package/ext-seo
label: 'Bootstrap Package: EXT:seo integration'
dependencies:
- typo3/seo-sitemap
16 changes: 16 additions & 0 deletions Configuration/Sets/ExtSeo/setup.typoscript
Original file line number Diff line number Diff line change
@@ -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/
}
}
}
5 changes: 5 additions & 0 deletions Configuration/Sets/Full/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions Configuration/Sets/Full/setup.typoscript
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
},
"typo3/cms": {
"extension-key": "bootstrap_package",
"Package": {
"serviceProvider": "BK2K\\BootstrapPackage\\ServiceProvider"
},
"web-dir": ".build/public"
}
},
Expand Down

0 comments on commit c6234ac

Please sign in to comment.