Skip to content

Commit

Permalink
Use sulu template attributes service (#15)
Browse files Browse the repository at this point in the history
* use template attributes service

* fix registration default template name
  • Loading branch information
alexander-schranz authored and wachterjohannes committed Jul 6, 2016
1 parent 15f59b7 commit 3b6b39d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
48 changes: 1 addition & 47 deletions Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,52 +161,6 @@ public function renderView($view, array $parameters = [])
*/
private function getTemplateAttributes($custom = [])
{
$defaults = [
'isCommunityTemplate' => true,
'extension' => [
'excerpt' => [
],
'seo' => [
],
],
'content' => [],
'shadowBaseLocale' => null,
];

$requestAnalyzer = $this->get('sulu_core.webspace.request_analyzer');

$default = array_merge(
$defaults,
$this->get('sulu_website.resolver.request_analyzer')->resolve($requestAnalyzer)
);

if (!isset($custom['urls'])) {
$router = $this->get('router');
$request = $this->get('request_stack')->getCurrentRequest();
$urls = [];

if ($request->get('_route')) {
foreach ($requestAnalyzer->getWebspace()->getLocalizations() as $localization) {
$url = $router->generate(
$request->get('_route'),
$request->get('_route_params')
);

// will remove locale because it will be added automatically
if (preg_match('/^\/[a-z]{2}(-[a-z]{2})?+\/(.*)/', $url)) {
$url = substr($url, strlen($localization->getLocale()) + 1);
}

$urls[$localization->getLocale()] = $url;
}
}

$custom['urls'] = $urls;
}

return array_merge(
$default,
$custom
);
return $this->get('sulu_website.resolver.template_attribute')->resolve($custom);
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
// Registration configuration
->scalarNode(self::TEMPLATE)->defaultValue('SuluCommunityBundle:Registration:profile-form.html.twig')->end()
->scalarNode(self::TEMPLATE)->defaultValue('SuluCommunityBundle:Registration:registration-form.html.twig')->end()
->scalarNode(self::FORM_TYPE)->defaultValue(RegistrationType::class)->end()
->arrayNode(self::FORM_TYPE_OPTIONS)
->addDefaultsIfNotSet()
Expand Down

0 comments on commit 3b6b39d

Please sign in to comment.