Skip to content

Commit

Permalink
NGSTACK-377: variables in template identifier configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Jan 28, 2020
1 parent 7ee3096 commit e25f512
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bundle/View/Provider/Configured.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function getDTO(array $viewConfig, ContentView $view): CoreContentView
$this->processRedirects($dto, $viewConfig, $view);

if (isset($viewConfig['template'])) {
$dto->setTemplateIdentifier($viewConfig['template']);
$dto->setTemplateIdentifier($this->replaceTemplateIdentifierVariables($viewConfig['template'], $view));
}

if (isset($viewConfig['controller'])) {
Expand All @@ -140,6 +140,13 @@ private function getDTO(array $viewConfig, ContentView $view): CoreContentView
return $dto;
}

private function replaceTemplateIdentifierVariables(string $identifier, ContentView $view): string
{
$contentTypeIdentifier = $view->getSiteContent()->contentInfo->contentTypeIdentifier;

return \preg_replace('/{content_type}/', $contentTypeIdentifier, $identifier) ?? $identifier;
}

/**
* @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $dto
* @param array $viewConfig
Expand Down

0 comments on commit e25f512

Please sign in to comment.