class CacheableViewsAjaxResponse in Views Ajax Get 2.0.x
Same name and namespace in other branches
- 8 src/CacheableViewsAjaxResponse.php \Drupal\views_ajax_get\CacheableViewsAjaxResponse
Hierarchy
- class \Drupal\Core\Ajax\AjaxResponse extends \Symfony\Component\HttpFoundation\JsonResponse implements AttachmentsInterface uses AttachmentsTrait
- class \Drupal\views\Ajax\ViewAjaxResponse
- class \Drupal\views_ajax_get\CacheableViewsAjaxResponse implements \Drupal\views_ajax_get\Serializable, CacheableResponseInterface uses CacheableResponseTrait
- class \Drupal\views\Ajax\ViewAjaxResponse
Expanded class hierarchy of CacheableViewsAjaxResponse
1 file declares its use of CacheableViewsAjaxResponse
- ViewsAjaxController.php in src/
Controller/ ViewsAjaxController.php
File
- src/
CacheableViewsAjaxResponse.php, line 11
Namespace
Drupal\views_ajax_getView source
class CacheableViewsAjaxResponse extends ViewAjaxResponse implements CacheableResponseInterface, \Serializable {
use CacheableResponseTrait;
/**
* {@inheritdoc}
*/
public function serialize() {
$vars = get_object_vars($this);
unset($vars['view']);
$vars['view_id'] = $this->view
->id();
$vars['display_id'] = $this->view->current_display;
return serialize($vars);
}
/**
* {@inheritdoc}
*/
public function unserialize($serialized) {
$unserialized = unserialize($serialized);
foreach ($unserialized as $key => $value) {
$this->{$key} = $value;
}
// Ensure that there is a request on the request stack.
$fake_request = FALSE;
if (!($request = \Drupal::request())) {
$fake_request = TRUE;
\Drupal::requestStack()
->push(Request::create('/uri'));
}
$this->view = Views::getView($unserialized['view_id']);
$this->view
->setDisplay($unserialized['display_id']);
if ($fake_request) {
\Drupal::requestStack()
->pop();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AjaxResponse:: |
protected | property | The array of ajax commands. | |
AjaxResponse:: |
public | function | Add an AJAX command to the response. | |
AjaxResponse:: |
public | function | Gets all AJAX commands. | |
AttachmentsTrait:: |
protected | property | The attachments for this response. | |
AttachmentsTrait:: |
public | function | ||
AttachmentsTrait:: |
public | function | ||
AttachmentsTrait:: |
public | function | ||
CacheableResponseTrait:: |
protected | property | The cacheability metadata. | |
CacheableResponseTrait:: |
public | function | ||
CacheableResponseTrait:: |
public | function | ||
CacheableViewsAjaxResponse:: |
public | function | ||
CacheableViewsAjaxResponse:: |
public | function | ||
ViewAjaxResponse:: |
protected | property | The view executed on this ajax request. | |
ViewAjaxResponse:: |
public | function | Gets the executed view of this response. | |
ViewAjaxResponse:: |
public | function | Sets the executed view of this response. |