Skip to content

Commit

Permalink
ignore disabled area bricks in autoload watcher pass (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat authored Aug 15, 2024
1 parent 6064f3f commit 66982e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Upgrade Notes

## 5.2.2
- [ENHANCEMENT] Ignore disabled area bricks in autoload watcher pass

## 5.2.1
- [BUGFIX] Fix column hash selector

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class AreaBrickAutoloadWatcherPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$disabledAreaBricks = $container->getParameter('toolbox.area_brick.disabled_bricks');
$config = $container->getParameter('pimcore.config');

if (!$config['documents']['areas']['autoload']) {
Expand All @@ -21,6 +22,11 @@ public function process(ContainerBuilder $container): void
$possibleNoPimcoreAwareBricks = [];

foreach ($container->getDefinitions() as $definitionId => $definition) {

if (in_array($definitionId, $disabledAreaBricks, true)) {
continue;
}

if (!str_contains((string) $definitionId, '.area.brick.')) {
continue;
}
Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/ToolboxExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public function load(array $configs, ContainerBuilder $container): void
$configManagerDefinition = $container->getDefinition(ConfigManager::class);
$configManagerDefinition->addMethodCall('setConfig', [$config]);

$disabledAreaBricks = array_filter($config['areas'], static function(array $area) {
return $area['enabled'] === false;
});

$container->setParameter('toolbox.area_brick.disabled_bricks', array_keys($disabledAreaBricks));
$container->setParameter('toolbox.area_brick.dialog_aware_bricks', $this->determinateConfigDialogAwareBricks($config));

//context resolver
Expand Down
7 changes: 5 additions & 2 deletions src/Manager/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ public function areaIsEnabled(string $areaName): bool
{
$this->ensureCoreConfig();

if (array_key_exists($areaName, $this->config['areas'])) {
return $this->config['areas'][$areaName]['enabled'] === true;
// keys cannot have dashes in symfony configuration, so replace if given
$saveKeyName = str_replace('-', '_', $areaName);

if (array_key_exists($saveKeyName, $this->config['areas'])) {
return $this->config['areas'][$saveKeyName]['enabled'] === true;
}

return true;
Expand Down

0 comments on commit 66982e4

Please sign in to comment.