HtmlResponse.php in Drupal 8
File
core/lib/Drupal/Core/Render/HtmlResponse.php
View source
<?php
namespace Drupal\Core\Render;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\CacheableResponseInterface;
use Drupal\Core\Cache\CacheableResponseTrait;
use Symfony\Component\HttpFoundation\Response;
class HtmlResponse extends Response implements CacheableResponseInterface, AttachmentsInterface {
use CacheableResponseTrait;
use AttachmentsTrait;
public function setContent($content) {
if (is_array($content) && isset($content['#markup'])) {
$content += [
'#attached' => [
'html_response_attachment_placeholders' => [],
'placeholders' => [],
],
];
$this
->addCacheableDependency(CacheableMetadata::createFromRenderArray($content));
$this
->setAttachments($content['#attached']);
$content = $content['#markup'];
}
return parent::setContent($content);
}
}
Classes
Name |
Description |
HtmlResponse |
A response that contains and can expose cacheability metadata and attachments. |