Merge pull request #1687 from ArthurHoaro/feature/template-name

Inject current template name in templates
This commit is contained in:
ArthurHoaro 2021-01-19 11:48:18 +01:00 committed by GitHub
commit 2fbdb7d657
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -56,6 +56,10 @@ protected function assignAllView(array $data): self
protected function render(string $template): string protected function render(string $template): string
{ {
// Legacy key that used to be injected by PluginManager
$this->assignView('_PAGE_', $template);
$this->assignView('template', $template);
$this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL)); $this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL));
$this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE)); $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE));

View file

@ -93,6 +93,9 @@ public function testRender(): void
static::assertSame('templateName', $render); static::assertSame('templateName', $render);
static::assertSame('templateName', $this->assignedValues['_PAGE_']);
static::assertSame('templateName', $this->assignedValues['template']);
static::assertSame(10, $this->assignedValues['linkcount']); static::assertSame(10, $this->assignedValues['linkcount']);
static::assertSame(5, $this->assignedValues['privateLinkcount']); static::assertSame(5, $this->assignedValues['privateLinkcount']);
static::assertSame(['error'], $this->assignedValues['plugin_errors']); static::assertSame(['error'], $this->assignedValues['plugin_errors']);