Skip to content

Commit

Permalink
Fix template setters in AbstractAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
wbloszyk committed Jan 11, 2021
1 parent f23ea1c commit 528b48e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1195,11 +1195,6 @@ final public function setTemplateRegistry(MutableTemplateRegistryInterface $temp
$this->templateRegistry = $templateRegistry;
}

/**
* @deprecated since sonata-project/admin-bundle 3.76, will be dropped in 4.0. Use TemplateRegistry services instead
*
* @param array<string, string> $templates
*/
public function setTemplates(array $templates)
{
// NEXT_MAJOR: Remove this line
Expand All @@ -1208,12 +1203,6 @@ public function setTemplates(array $templates)
$this->getTemplateRegistry()->setTemplates($templates);
}

/**
* @deprecated since sonata-project/admin-bundle 3.76, will be dropped in 4.0. Use TemplateRegistry services instead
*
* @param string $name
* @param string $template
*/
public function setTemplate($name, $template)
{
// NEXT_MAJOR: Remove this line
Expand Down
2 changes: 1 addition & 1 deletion src/Templating/MutableTemplateRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class MutableTemplateRegistry extends AbstractTemplateRegistry implements
// public function setTemplates(array $templates): void
public function setTemplates(array $templates)
{
$this->templates = $templates;
$this->templates = array_merge($this->templates, $templates);
}

// NEXT_MAJOR: change method declaration for new one
Expand Down
19 changes: 19 additions & 0 deletions src/Templating/MutableTemplateRegistryAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,23 @@ interface MutableTemplateRegistryAwareInterface

// NEXT_MAJOR: uncomment this method in 4.0
//public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void;

/**
* NEXT_MAJOR: remove this method declaration with docblock and uncomment code below.
*
* @param string $name
* @param string $template
*/
public function setTemplate($name, $template);

//public function setTemplate(string $name, string $template);

/**
* NEXT_MAJOR: remove this method declaration and uncomment code below.
*
* @param array<string, string> $templates
*/
public function setTemplates(array $templates);

//public function setTemplates(array $templates): void;
}
2 changes: 1 addition & 1 deletion tests/Templating/MutableTemplateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testGetTemplates(): void
];

$this->templateRegistry->setTemplates($templates);
$this->assertSame($templates, $this->templateRegistry->getTemplates());
$this->assertSame(array_merge(['list' => '@FooAdmin/CRUD/list.html.twig'], $templates), $this->templateRegistry->getTemplates());
}

/**
Expand Down

0 comments on commit 528b48e

Please sign in to comment.