Feature #101909
openMake it possible to activate / deactive packages (extensions) from Feature toggles
0%
Description
We have extension A and the new extension B. In extension A we have added som feature toggles on code that uses extension B.
Currently on our testing site we activate the featuretoggle to test things, but manually have to add the extension B package from composer, breaking our deploy setup.
Also we might want to test the new feature on only one of multiple Production/Live instances of the same TYPO3 solution, which also presents the same problem.
It would be nice if we could add extension B to the main branch and have it activated through the feature toggle.
Updated by Stig Nørgaard Færch 8 months ago
- Tracker changed from Bug to Feature
- TYPO3 Version deleted (
11)
Updated by Stig Nørgaard Færch 8 months ago
Just experimented a bit with the PackageManager and got something working, though of course not tested thoroughly, and it may or maybe not be a viable solution:
\TYPO3\CMS\Core\Package\PackageManager::getActivePackages
public function getActivePackages()
{
if (empty($this->activePackages)) {
if (!empty($this->packageStatesConfiguration['packages'])) {
foreach ($this->packageStatesConfiguration['packages'] as $packageKey => $packageConfig) {
$addAsActivePackage = true;
if($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableExtensionByFeatureToggle'][$packageKey] ?? false) {
$addAsActivePackage = GeneralUtility::makeInstance(Features::class)->isFeatureEnabled($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableExtensionByFeatureToggle'][$packageKey]);
}
if($addAsActivePackage) $this->activePackages[$packageKey] = $this->getPackage($packageKey);
}
}
}
return $this->activePackages;
}
So I my additionalConfiguration.php file, I would of course have my feature toggle settings and this new one:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableExtensionByFeatureToggle']['news'] = 'myFeatureName';
Updated by Stig Nørgaard Færch 8 months ago
As some points out on Slack. My suggestion to a solution might bring big trouble as patching getActivePackages for runtime extensions might introduce a lot of DI-cache and other TYPO3-cache issues...
For my example, one suggests me make anything in the extension B gated from the feature toggle as well. That could be a lot of conditions all over. Another point is, that this might be a 3rd party extension, and not a in house extension. So that would require to hack the extension instead.