I am using a custom module to create a new page on my Drupal 8 site.
My routing.yml
file is configured like this:
mymodule.print:
path: '/print-mymodule'
defaults:
_controller: \Drupal\mymodule\Controller\MymodulePrintController::content
requirements:
_permission: 'view mymodule entity'
options:
_auth: ['basic_auth']
MymodulePrintController::content
is as follows:
public function content() {
return array(
'#type' => 'page',
'#theme' => 'mytheme'
);
}
mytheme
is used everywhere else on my site.
In mytheme.theme
, I also have a mytheme_preprocess()
function which is adding some blocks to the page. I am guessing the theme is being detected properly because this function is executing just fine. The template I am using is named according to twig's suggestions and is loading fine.
The problem is that the content()
function is not really outputting a "page". Using Postman, I see that the entire contents of the response is just a div, there is no <html>
tag, no <head>
, no <body>
, nothing else except what is defined in the one twig file and mytheme_preprocess
. I need this page to be using this theme's css styles like the rest of my pages are.
How can I accomplish this? Every guide/question I've seen on the topic so far either is just returning a render array in the content()
function like I already am doing, or is suggesting to use Response
classes without enough detail for me to really understand.