Returns responses for Contextual module routes.
Expanded class hierarchy of ContextualController
class ContextualController extends ContainerAware {
/**
* Returns the requested rendered contextual links.
*
* Given a list of contextual links IDs, render them. Hence this must be
* robust to handle arbitrary input.
*
* @see contextual_preprocess()
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* The JSON response.
*/
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] = drupal_render($element);
}
return new JsonResponse($rendered);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContainerAware:: |
protected | property | @api | |
ContainerAware:: |
public | function |
Sets the Container associated with this Controller. Overrides ContainerAwareInterface:: |
|
ContextualController:: |
public | function | Returns the requested rendered contextual links. |