Skip to content

Commit

Permalink
Improve AddDependencyCallsCompilerPass
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and OskarStark committed Dec 15, 2020
1 parent ca03072 commit 36bd245
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function applyConfigurationFromAttribute(Definition $definition, array $a
'translator',
'configuration_pool',
'router',
'validator', //NEXT_MAJOR: Remove this line
'validator', // NEXT_MAJOR: Remove this line
'security_handler',
'menu_factory',
'route_builder',
Expand Down Expand Up @@ -281,7 +281,12 @@ public function applyDefaults(ContainerBuilder $container, $serviceId, array $at
'translator' => 'translator',
'configuration_pool' => 'sonata.admin.pool',
'route_generator' => 'sonata.admin.route.default_generator',
<<<<<<< HEAD
'validator' => 'validator', //NEXT_MAJOR: Remove this line
=======
// NEXT_MAJOR: Remove this line.
'validator' => 'validator',
>>>>>>> e3f653f61... Improve AddDependencyCallsCompilerPass
'security_handler' => 'sonata.admin.security.handler',
'menu_factory' => 'knp_menu.factory',
'route_builder' => 'sonata.admin.route.path_info'.
Expand Down Expand Up @@ -309,49 +314,26 @@ public function applyDefaults(ContainerBuilder $container, $serviceId, array $at
}
}

if (isset($overwriteAdminConfiguration['pager_type'])) {
$pagerType = $overwriteAdminConfiguration['pager_type'];
} elseif (isset($attributes['pager_type'])) {
$pagerType = $attributes['pager_type'];
} else {
$pagerType = Pager::TYPE_DEFAULT;
}

$pagerType = $overwriteAdminConfiguration['pager_type'] ?? $attributes['pager_type'] ?? Pager::TYPE_DEFAULT;
$definition->addMethodCall('setPagerType', [$pagerType]);

if (isset($overwriteAdminConfiguration['label'])) {
$label = $overwriteAdminConfiguration['label'];
} elseif (isset($attributes['label'])) {
$label = $attributes['label'];
} else {
$label = '-';
}

// NEXT_MAJOR: Default to null
$label = $overwriteAdminConfiguration['label'] ?? $attributes['label'] ?? '-';
$definition->addMethodCall('setLabel', [$label]);

$persistFilters = $container->getParameter('sonata.admin.configuration.filters.persist');
// override default configuration with admin config if set
if (isset($attributes['persist_filters'])) {
$persistFilters = $attributes['persist_filters'];
}
$filtersPersister = $container->getParameter('sonata.admin.configuration.filters.persister');
// override default configuration with admin config if set
if (isset($attributes['filter_persister'])) {
$filtersPersister = $attributes['filter_persister'];
}
$persistFilters = $attributes['persist_filters']
?? $container->getParameter('sonata.admin.configuration.filters.persist');
$filtersPersister = $attributes['filter_persister']
?? $container->getParameter('sonata.admin.configuration.filters.persister');

// configure filters persistence, if configured to
if ($persistFilters) {
$definition->addMethodCall('setFilterPersister', [new Reference($filtersPersister)]);
}

if (isset($overwriteAdminConfiguration['show_mosaic_button'])) {
$showMosaicButton = $overwriteAdminConfiguration['show_mosaic_button'];
} elseif (isset($attributes['show_mosaic_button'])) {
$showMosaicButton = $attributes['show_mosaic_button'];
} else {
$showMosaicButton = $container->getParameter('sonata.admin.configuration.show.mosaic.button');
}

$showMosaicButton = $overwriteAdminConfiguration['show_mosaic_button']
?? $attributes['show_mosaic_button']
?? $container->getParameter('sonata.admin.configuration.show.mosaic.button');
$definition->addMethodCall('showMosaicButton', [$showMosaicButton]);

$this->fixTemplates(
Expand Down

0 comments on commit 36bd245

Please sign in to comment.