setContent($content); } /** * Sets the response content. * * @param mixed $content * Content that can be cast to string, or a render array. * * @return $this */ public function setContent($content): static { // A render array can automatically be converted to a string and set the // necessary metadata. 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); } }