public function ContextualController::render in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/contextual/src/ContextualController.php \Drupal\contextual\ContextualController::render()
Returns the requested rendered contextual links.
Given a list of contextual links IDs, render them. Hence this must be robust to handle arbitrary input.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
See also
1 string reference to 'ContextualController::render'
- contextual.routing.yml in core/
modules/ contextual/ contextual.routing.yml - core/modules/contextual/contextual.routing.yml
File
- core/
modules/ contextual/ src/ ContextualController.php, line 34 - Contains \Drupal\contextual\ContextualController.
Class
- ContextualController
- Returns responses for Contextual module routes.
Namespace
Drupal\contextualCode
public function render(Request $request) {
$ids = $request->request
->get('ids');
if (!isset($ids)) {
throw new BadRequestHttpException(t('No contextual ids specified.'));
}
$rendered = array();
foreach ($ids as $id) {
$element = array(
'#type' => 'contextual_links',
'#contextual_links' => _contextual_id_to_links($id),
);
$rendered[$id] = $this->container
->get('renderer')
->renderRoot($element);
}
return new JsonResponse($rendered);
}