Skip to content

Commit

Permalink
only add method call if there is none already
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Apr 29, 2021
1 parent fcb0ce2 commit 5fda8dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,12 @@ public function applyDefaults(ContainerBuilder $container, $serviceId, array $at
$definition->addMethodCall('setSecurityInformation', ['%sonata.admin.configuration.security.information%']);
}

$definition->addMethodCall('setFormTheme', [$overwriteAdminConfiguration['templates']['form'] ?? []]);
$definition->addMethodCall('setFilterTheme', [$overwriteAdminConfiguration['templates']['filter'] ?? []]);
if (!$definition->hasMethodCall('setFormTheme')) {
$definition->addMethodCall('setFormTheme', [$overwriteAdminConfiguration['templates']['form'] ?? []]);
}
if (!$definition->hasMethodCall('setFilterTheme')) {
$definition->addMethodCall('setFilterTheme', [$overwriteAdminConfiguration['templates']['filter'] ?? []]);
}

return $definition;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,29 @@ public function testProcessResultingConfig(): void
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sonata_article_admin',
'sonata_news_admin',
'setFormTheme',
[[]]
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sonata_article_admin',
'sonata_news_admin',
'setFilterTheme',
[[]]
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sonata_article_admin',
'setFormTheme',
[['custom_form_theme.twig']]
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sonata_article_admin',
'setFilterTheme',
[['custom_filter_theme.twig']]
);

$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'sonata_post_admin',
'setFormTheme',
Expand Down Expand Up @@ -626,6 +638,12 @@ protected function getConfig()
'view' => ['user_block' => 'foo.twig.html'],
],
],
'sonata_article_admin' => [
'templates' => [
'form' => ['some_form_template.twig'],
'filter' => ['some_filter_template.twig'],
],
],
],
];
}
Expand Down Expand Up @@ -662,7 +680,9 @@ private function setUpContainer(): void
->setPublic(true)
->setClass(MockAdmin::class)
->setArguments(['', Article::class, CRUDController::class])
->addTag('sonata.admin', ['group' => 'sonata_group_one', 'label' => '1 Entry', 'manager_type' => 'doctrine_phpcr']);
->addTag('sonata.admin', ['group' => 'sonata_group_one', 'label' => '1 Entry', 'manager_type' => 'doctrine_phpcr'])
->addMethodCall('setFormTheme', [['custom_form_theme.twig']])
->addMethodCall('setFilterTheme', [['custom_filter_theme.twig']]);
$this->container
->register('sonata_report_admin')
->setPublic(true)
Expand Down

0 comments on commit 5fda8dc

Please sign in to comment.