class ViewsAjaxController in Views Ajax Get 8
Same name and namespace in other branches
- 2.0.x src/Controller/ViewsAjaxController.php \Drupal\views_ajax_get\Controller\ViewsAjaxController
Controller that allows for Views AJAX GET requests that can be cached.
Hierarchy
- class \Drupal\views\Controller\ViewAjaxController implements ContainerInjectionInterface
- class \Drupal\views_ajax_get\Controller\ViewsAjaxController
Expanded class hierarchy of ViewsAjaxController
File
- src/
Controller/ ViewsAjaxController.php, line 13
Namespace
Drupal\views_ajax_get\ControllerView source
class ViewsAjaxController extends ViewAjaxController {
/**
* {@inheritdoc}
*/
public function ajaxView(Request $request) {
if ($request
->getMethod() !== Request::METHOD_GET) {
return parent::ajaxView($request);
}
// Add all query parameters to the post variable, because this is what
// \Drupal\views\Controller\ViewAjaxController::ajaxView expects.
$request->request
->add($request->query
->all());
$response = parent::ajaxView($request);
$view = $response
->getView();
if (_views_ajax_get_is_ajax_get_view($view)) {
$cacheable_response = new CacheableViewsAjaxResponse();
$cacheable_response
->setView($view);
$cacheable_commands =& $cacheable_response
->getCommands();
$cacheable_commands = $response
->getCommands();
$view_metadata = CacheableMetadata::createFromRenderArray($view->element);
$metadata = $cacheable_response
->getCacheableMetadata();
$metadata
->addCacheableDependency($view_metadata);
// Don't allow attachments
// $cacheable_response->setAttachments($response->getAttachments());
return $cacheable_response;
}
return $response;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ViewAjaxController:: |
protected | property | The current path. | |
ViewAjaxController:: |
protected | property | The factory to load a view executable with. | |
ViewAjaxController:: |
protected | property | The redirect destination. | |
ViewAjaxController:: |
protected | property | The renderer. | |
ViewAjaxController:: |
protected | property | The entity storage for views. | |
ViewAjaxController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ViewAjaxController:: |
public | function | Constructs a ViewAjaxController object. | |
ViewsAjaxController:: |
public | function |
Loads and renders a view via AJAX. Overrides ViewAjaxController:: |