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

Rename renderTemplate to render for consistency with AbstractController #1735

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/Controller/Backend/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function login(AuthenticationUtils $authenticationUtils): Response
// last authentication error (if any)
$error = $authenticationUtils->getLastAuthenticationError();

return $this->renderTemplate('@bolt/security/login.html.twig', [
return $this->render('@bolt/security/login.html.twig', [
'last_username' => $last_username,
'error' => $error,
]);
Expand Down Expand Up @@ -54,6 +54,6 @@ public function resetPassword(): Response
'subtitle' => 'controller.authentication.reset_subtitle',
];

return $this->renderTemplate('@bolt/pages/placeholder.html.twig', $twigVars);
return $this->render('@bolt/pages/placeholder.html.twig', $twigVars);
}
}
6 changes: 3 additions & 3 deletions src/Controller/Backend/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function edit(Content $content): Response
'currentlocale' => $this->getEditLocale($content),
];

return $this->renderTemplate('@bolt/content/edit.html.twig', $twigvars);
return $this->render('@bolt/content/edit.html.twig', $twigvars);
}

/**
Expand Down Expand Up @@ -182,7 +182,7 @@ public function preview(?Content $content = null): Response

$templates = $this->templateChooser->forRecord($content);

return $this->renderTemplate($templates, $context);
return $this->render($templates, $context);
}

/**
Expand Down Expand Up @@ -210,7 +210,7 @@ public function duplicate(Content $content): Response
'defaultlocale' => $this->defaultLocale,
];

return $this->renderTemplate('@bolt/content/edit.html.twig', $twigvars);
return $this->render('@bolt/content/edit.html.twig', $twigvars);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/ContentLocalizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function locales(Content $content): Response
{
$content->getFields();

return $this->renderTemplate('@bolt/content/view_locales.html.twig', [
return $this->render('@bolt/content/view_locales.html.twig', [
'record' => $content,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function index(Query $query): Response

$records = $pager->setCurrentPage($page);

return $this->renderTemplate('@bolt/pages/dashboard.html.twig', [
return $this->render('@bolt/pages/dashboard.html.twig', [
'records' => $records,
'filter_value' => $filter,
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Backend/DatabaseIntegrityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function check(): Response
'subtitle' => 'controller.database.check_subtitle',
];

return $this->renderTemplate('@bolt/pages/placeholder.html.twig', $twigVars);
return $this->render('@bolt/pages/placeholder.html.twig', $twigVars);
}

/**
Expand All @@ -37,6 +37,6 @@ public function update(): Response
'subtitle' => 'controller.database.update_title',
];

return $this->renderTemplate('@bolt/pages/placeholder.html.twig', $twigVars);
return $this->render('@bolt/pages/placeholder.html.twig', $twigVars);
}
}
4 changes: 2 additions & 2 deletions src/Controller/Backend/FileEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function edit(string $location): Response
'writable' => is_writable($filename),
];

return $this->renderTemplate('@bolt/finder/editfile.html.twig', $context);
return $this->render('@bolt/finder/editfile.html.twig', $context);
}

/**
Expand Down Expand Up @@ -99,7 +99,7 @@ public function save(UrlGeneratorInterface $urlGenerator): Response
'writable' => is_writable($filename),
];

return $this->renderTemplate('@bolt/finder/editfile.html.twig', $context);
return $this->render('@bolt/finder/editfile.html.twig', $context);
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/FilemanagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function filemanager(string $location): Response

$parent = $path !== '/' ? Path::canonicalize($path . '/..') : '';

return $this->renderTemplate('@bolt/finder/finder.html.twig', [
return $this->render('@bolt/finder/finder.html.twig', [
'path' => $path,
'location' => $location,
'finder' => $pager,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/FixturesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function fixtures(): Response
'subtitle' => 'To add Fixtures, or "Dummy Content".',
];

return $this->renderTemplate('@bolt/pages/placeholder.html.twig', $twigVars);
return $this->render('@bolt/pages/placeholder.html.twig', $twigVars);
}
}
4 changes: 2 additions & 2 deletions src/Controller/Backend/GeneralController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function about(): Response
'os_version' => php_uname('r'),
];

return $this->renderTemplate('@bolt/pages/about.html.twig', $twigVars);
return $this->render('@bolt/pages/about.html.twig', $twigVars);
}

/**
Expand All @@ -64,6 +64,6 @@ public function kitchensink(ContentRepository $content, Config $config): Respons
'records' => $records,
];

return $this->renderTemplate('@bolt/pages/kitchensink.html.twig', $twigVars);
return $this->render('@bolt/pages/kitchensink.html.twig', $twigVars);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Backend/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function overview(Query $query, string $contentType = ''): Response

$records = $pager->setCurrentPage($page);

return $this->renderTemplate('@bolt/content/listing.html.twig', [
return $this->render('@bolt/content/listing.html.twig', [
'contentType' => $contentTypeObject,
'records' => $records,
'sortBy' => $this->getFromRequest('sortBy'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/LogViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function index(LogRepository $log): Response
/** @var Log $items */
$items = $log->findLatest($page, $amount);

return $this->renderTemplate('@bolt/pages/logviewer.html.twig', [
return $this->render('@bolt/pages/logviewer.html.twig', [
'items' => $items,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function finder(string $locationName): Response

$this->em->flush();

return $this->renderTemplate('@bolt/finder/finder.twig', [
return $this->render('@bolt/finder/finder.twig', [
'path' => 'path',
'name' => $this->fileLocations->get($locationName)->getName(),
'location' => $locationName,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/MediaEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function edit(?Media $media = null): Response
'media' => $media,
];

return $this->renderTemplate('@bolt/media/edit.html.twig', $context);
return $this->render('@bolt/media/edit.html.twig', $context);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/MenuPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function menuPage(string $slug): Response
'subtitle' => 'To show a number of different things, on one page',
];

return $this->renderTemplate('@bolt/pages/menupage.html.twig', $twigVars);
return $this->render('@bolt/pages/menupage.html.twig', $twigVars);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Backend/OmnisearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function omnisearch(): Response
'subtitle' => 'controller.omnisearch.subtitle',
];

return $this->renderTemplate('@bolt/pages/placeholder.html.twig', $twigVars);
return $this->render('@bolt/pages/placeholder.html.twig', $twigVars);
}
}
4 changes: 2 additions & 2 deletions src/Controller/Backend/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function edit(): Response
{
$user = $this->getUser();

return $this->renderTemplate('@bolt/users/profile.html.twig', [
return $this->render('@bolt/users/profile.html.twig', [
'display_name' => $user->getDisplayName(),
'user' => $user,
]);
Expand Down Expand Up @@ -93,7 +93,7 @@ public function save(ValidatorInterface $validator): Response

$suggestedPassword = $hasPasswordError ? Str::generatePassword() : null;

return $this->renderTemplate('@bolt/users/profile.html.twig', [
return $this->render('@bolt/users/profile.html.twig', [
'display_name' => $displayName,
'userEdit' => $user,
'suggestedPassword' => $suggestedPassword,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public function users(Query $query): Response
'users' => $users,
];

return $this->renderTemplate('@bolt/users/listing.html.twig', $twigVars);
return $this->render('@bolt/users/listing.html.twig', $twigVars);
}
}
4 changes: 2 additions & 2 deletions src/Controller/Backend/UserEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function edit(?User $user): Response
$roles = array_merge($this->getParameter('security.role_hierarchy.roles'), $event->getRoleOptions()->toArray());
$statuses = UserStatus::all();

return $this->renderTemplate('@bolt/users/edit.html.twig', [
return $this->render('@bolt/users/edit.html.twig', [
'display_name' => $user->getDisplayName(),
'userEdit' => $user,
'roles' => $roles,
Expand Down Expand Up @@ -179,7 +179,7 @@ public function save(?User $user, ValidatorInterface $validator): Response

$suggestedPassword = $hasPasswordError ? Str::generatePassword() : null;

return $this->renderTemplate('@bolt/users/edit.html.twig', [
return $this->render('@bolt/users/edit.html.twig', [
'display_name' => $displayName,
'userEdit' => $user,
'suggestedPassword' => $suggestedPassword,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Frontend/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public function listing(ContentRepository $contentRepository, string $contentTyp
'contenttype' => $contentType,
];

return $this->renderTemplate($templates, $twigVars);
return $this->render($templates, $twigVars);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Frontend/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public function search(ContentRepository $contentRepository): Response

$templates = $this->templateChooser->forSearch();

return $this->renderTemplate($templates, $context);
return $this->render($templates, $context);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Frontend/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function listing(ContentRepository $contentRepository, string $taxonomysl
'slug' => $slug,
];

return $this->renderTemplate($templates, $twigVars);
return $this->render($templates, $twigVars);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Frontend/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function template(string $templateName): Response
{
$templates = [$templateName];

return $this->renderTemplate($templates, []);
return $this->render($templates, []);
}
}
12 changes: 10 additions & 2 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ public function setAutowire(Config $config, Environment $twig, Packages $package
$this->templateChooser = $templateChooser;
}

/**
* @deprecated since Bolt 4.0, use "render()" instead
*/
public function renderTemplate($template, array $parameters = [], ?Response $response = null): Response
{
return $this->render($template, $parameters, $response);
}

/**
* Renders a view.
*
* @param string|array $template
*/
public function renderTemplate($template, array $parameters = [], ?Response $response = null): Response
public function render($template, array $parameters = [], ?Response $response = null): Response
{
// Set User in global Twig environment
$parameters['user'] = $parameters['user'] ?? $this->getUser();
Expand Down Expand Up @@ -140,7 +148,7 @@ public function renderSingle(?Content $record, bool $requirePublished = true, ar
$templates = $this->templateChooser->forRecord($record);
}

return $this->renderTemplate($templates, $context);
return $this->render($templates, $context);
}

private function setTwigLoader(): void
Expand Down