-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set twig globals after first admin instanciation
Fixes #8120
- Loading branch information
Antoine Roué
committed
Nov 19, 2023
1 parent
724c4fc
commit 7954685
Showing
7 changed files
with
64 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ | |
use Symfony\Component\Validator\ConstraintViolation; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
use Twig\Loader\ArrayLoader; | ||
|
||
/** | ||
* @author Andrej Hudec <[email protected]> | ||
|
@@ -383,6 +384,32 @@ public function testConfigureAdminWithoutTemplateRegistryThrowsException(): void | |
$controller->configureAdmin($this->request); | ||
} | ||
|
||
public function testSetTwigGlobals(): void | ||
{ | ||
$twig = new Environment(new ArrayLoader([])); | ||
$this->container->set('twig', $twig); | ||
|
||
$this->controller->setTwigGlobals($this->request); | ||
|
||
$globals = $twig->getGlobals(); | ||
static::assertSame($this->admin, $globals['admin']); | ||
static::assertSame('@SonataAdmin/standard_layout.html.twig', $globals['base_template']); | ||
} | ||
|
||
public function testSetTwigGlobalsWithAjaxRequest(): void | ||
{ | ||
$this->request->request->set('_xml_http_request', true); | ||
|
||
$twig = new Environment(new ArrayLoader([])); | ||
$this->container->set('twig', $twig); | ||
|
||
$this->controller->setTwigGlobals($this->request); | ||
|
||
$globals = $twig->getGlobals(); | ||
static::assertSame($this->admin, $globals['admin']); | ||
static::assertSame('@SonataAdmin/ajax_layout.html.twig', $globals['base_template']); | ||
} | ||
|
||
public function testGetBaseTemplate(): void | ||
{ | ||
static::assertSame( | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters