Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin template setters #6766

Merged
merged 2 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 2 additions & 0 deletions src/Templating/MutableTemplateRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ final class MutableTemplateRegistry extends AbstractTemplateRegistry implements
// public function setTemplates(array $templates): void
public function setTemplates(array $templates)
{
//NEXT_MAJOR: use array merge and update the doc https://github.com/sonata-project/SonataAdminBundle/blob/3.x/docs/reference/templates.rst
wbloszyk marked this conversation as resolved.
Show resolved Hide resolved
$this->templates = $templates;
//$this->templates = $templates + $this->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: 2 additions & 0 deletions tests/Templating/MutableTemplateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public function testGetTemplates(): void
];

$this->templateRegistry->setTemplates($templates);
// NEXT_MAJOR: remove this first assert and uncomment second
$this->assertSame($templates, $this->templateRegistry->getTemplates());
//$this->assertSame($templates + ['list' => '@FooAdmin/CRUD/list.html.twig'], $this->templateRegistry->getTemplates());
}

/**
Expand Down