Questions tagged [page-controller]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
66 views

Why am I getting "Page not found" for a simple "hello world" custom page

In my custom module, ed_helper, I have this ed_helper.routing.yml: ed_helper.my_page: path: '/mypage/page' defaults: _controller: '\Drupal\ed_helper\Controller\EdHelperController::myPage' ...
arnoldbird's user avatar
  • 1,079
0 votes
0 answers
18 views

Avoid TypeError when route with type hinted parameter in controller is called with wrong parameter type

We defined a route under which a visitor of the website can find some information about how to get data related to the currently shown entity: aw_api.open_data.info: path: '/open-data/info/{...
Tobias Krause's user avatar
-1 votes
1 answer
147 views

"No route found for GET" on custom REST resource when posting

I'm seeing really weird behavior. I've created a custom REST resource at the route /user/login-special. This is a passwordless login resource, so I pass the mail address and then get a response that ...
Patrick Kenny's user avatar
0 votes
1 answer
199 views

Stripe doesn't see API key after TrustedRedirectResponse

I have a controller that calls the Stripe API using stripe-php to create a checkout session. /** * Checkout using Stripe. * * @param \Symfony\Component\HttpFoundation\Request $request * ...
mbomb007's user avatar
  • 516
0 votes
1 answer
46 views

How do I get my custom module controller logic to trigger on only certain url paths?

Hi all I am very new to Drupal and am trying to write a custom module. So my site has a bunch of different urls for example example.com/users/3 or example.com/articles/47. I want my custom module code ...
Paige's user avatar
  • 1
1 vote
0 answers
53 views

How do I set/get cookies in a controller (custom module)? [duplicate]

I have a module and I need to set a simple cookie (if not exists). And after each request I need to read the value of the cookie and maybe update. I have read many articles and tried many ways but no ...
Eryk's user avatar
  • 3
0 votes
0 answers
165 views

How can I add inline JavaScript on a page returned from a custom controller (not with a library)?

How can I add another render element that contains my custom JavaScript code? Do I use ['#attached']['html_head'] or code similar to the following one? $build['body']['script'] = [ '#type' => '...
mevsme's user avatar
  • 1
0 votes
0 answers
458 views

"LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected."

Hi I've created a module with a controller but now i'm getting this message; The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you ...
skycomputer2's user avatar
2 votes
1 answer
482 views

Return AccessDenied for custom page

I've setup a custom page in my system which is expecting 2 parameters that will be used to generate part of the content on that page, I'm able to retrieve the information from my page, but I'm ...
Andrew Morris's user avatar
0 votes
0 answers
158 views

Off-site payment gateway success/failure return is caught by a differnt custom module

I have created an offsite (redirect form) payment gateway Drupal 8 module for Opayo.co.uk. following drupal commerce documentation. Issue: My custom off-site payment gateway module based on form ...
Monsoonpk's user avatar
0 votes
1 answer
45 views

Override a access check but also pass control back to the primary controller under certain conditions?

I use a contrib controller that has a _custom_access function that I need to override. I add a RouteSubscriber, and point the access check to my own controller. Now I want something like: if ($...
Letharion's user avatar
  • 27.5k
0 votes
0 answers
53 views

How to Manage Webhook Notifications?

I had developed a controller to retrieve data from an API via a webhook. This is the type of data I received with https://webhook.site for testing : { "owner": { "id": "...
Sébastien Gicquel's user avatar
0 votes
1 answer
1k views

How to configure a custom POST api to accept a request with Content-Type as "application/x-www-form-urlencoded" in the header?

I created a controller in a custom module that accepts a POST request. I have a setup such that I get a POST request from a third-party application server to this API. But the POST request has a ...
Kiran Dhakal's user avatar
0 votes
2 answers
256 views

How can i render a file using a formatter programmatically in a controller?

I'm trying to create a controller to render a swagger documentation using the module swagger_ui_formatter that provide a formatter to the file field that render swagger files (yml, yaml, json) using ...
Mauricio's user avatar
  • 107
0 votes
0 answers
391 views

Alter a controller's render array via KernelEvents::VIEW

I'm trying to alter a contrib module controller's output via KernelEvents::VIEW. I want to display the output from the controller and append the markup returned from the event handler. This is the ...
Nicholas's user avatar
1 vote
1 answer
201 views

How can I delete a file served by a custom controller after it has been downloaded?

Starting from How do I create a file download URL? I've build a custom controller that allows users to download a PDF file. my_module.routing.yml my_module.pdf_link: path: '/my-module/pdf/download' ...
Giuseppe's user avatar
  • 897
-2 votes
1 answer
86 views

Adding select list to tableselect output

I'm trying to add a select-list to some table output but the markup is rendering as text. $header = [ 'col1' => t('COL1'), 'col2' => t('COL2'), ]; $rows = [ 1 => [ 'col1' => '...
sisko's user avatar
  • 1,710
0 votes
1 answer
33 views

How to force display of a specific page of paged data

I'm displaying a table of dated items ordered from old to new and am using the full pager. How can I force my page to initially display those items that are current ie. on initial load, display the ...
peterbe's user avatar
0 votes
2 answers
149 views

Custom access method for a Page Manager page

I've created a page using Page Manager, at the route /project/(node}/attendance. I need to add a custom access check on it, comparing information about the current user with the node to see if they ...
dmgig's user avatar
  • 129
1 vote
1 answer
85 views

Keep entity object after getTitle() method in render() method in a custom controller

I've setup my controller like this: my_controller: path: '/controller/{id}' defaults: _controller: '\Drupal\Mymodule\Controller\MyController::Render' _title_callback: '\Drupal\Mymodule\...
Stef Van Looveren's user avatar
0 votes
1 answer
502 views

Is there a way to get the controller class from a Request object or any other service class?

My controller class holds some not-so-easy logic to receive some data from a route parameter I need in a block plugin. As this block will only be rendered on this specific route, I would like to ...
Tobias Krause's user avatar
1 vote
0 answers
273 views

Use one controller in custom Block and Page

I have a custom module with a page and block. Both will use same API but with different queries and also both will display API data in the same page. To be more explicit, I have a simple search on my ...
Pedro's user avatar
  • 144
0 votes
1 answer
95 views

Controller is loading twice after search form is submitted

I created a custom module that I consume an external api. I have also created a custom form (its action points to controller url) which filters the data. However, when I press the search button and ...
Dimitris Markopoulos's user avatar
0 votes
1 answer
506 views

Access hook_preprocess_node variables from page controller

I have a custom controller created for a custom URL, where the URL is a URL for an existing node with an additional parameter. The display for the URL defined by the controller needs to use the the ...
wonder95's user avatar
  • 1,201
0 votes
1 answer
654 views

submitForm() isn't called

Goal: Have a custom page that shows various elements including links, logos, images and a custom form to help the users reset their passwords (we have a custom reset password interface which sends the ...
dylhof's user avatar
  • 1
1 vote
1 answer
141 views

How can I avoid to return HTML markup for access denied? [duplicate]

I've developed a custom controller that serves as a simple endpoint, POST method. This controller has custom access control. Custom access is done by looking for a header in the HTTP request, by ...
jackrabbithanna's user avatar
0 votes
1 answer
2k views

LogicException : The controller must return a response (success ! given) [duplicate]

i have a service that return for me true in the node (article) successfully create and false if something wrong , but in the controller i am getting this error 'LogicException : The controller must ...
David montera's user avatar
0 votes
1 answer
186 views

How can I render more than one field value in the controller?

in my case i have a controller that it send for me the title , to the view , but i want to send the tittle and the body of the article both , i have tried to send them from the controller but it doesn'...
David montera's user avatar
1 vote
1 answer
876 views

Custom POST request [duplicate]

I am very new to Drupal. My project requires me to create a custom module. I am working with Headless Drupal and I want to make a POST request. I cannot pass the POSTMAN Body to my Request argument in ...
Suchismita Banerjee's user avatar
-1 votes
1 answer
203 views

Why do I get an error related to a controller when I created a custom module?

I created custom module following the Creating a custom module on Drupal tutorial. The teacher of this tutorial demonstrated how you can create a custom module that displays on the page Hello world. ...
antongordon25's user avatar
1 vote
0 answers
189 views

What is the difference between access method in controller and custom access check

I am trying to create a module with custom access checks. I would like to know what additional features does implementing AccessInterface provide. For example I can check access within the ...
miststudent2011's user avatar
0 votes
0 answers
249 views

Custom module with same twig template and two paths (e.g /pub and /pub/{id} )

I created a custom module to show nodes by taxonomy in a specific html twig. I created a controller that contain two functions. The first function called "content" pass an array to template twig ...
youssef hrizi's user avatar
0 votes
2 answers
246 views

Creating a route with a form and some content

i have created a route with a form: amu_404_redirect_import.admin: path: '/admin/config/amu_404_redirect_import/upload' defaults: _form: '\Drupal\amu_404_redirect_import\Form\...
Matoeil's user avatar
  • 3,359
0 votes
1 answer
568 views

Redirect from within controller always goes to home page

I have a custom module named rsc. My Default 404 (not found) page is set to /page-not-found in Basic site settings. My rsc.routing.yml file contains rsc.pageNotFound: path: '/page-not-found' ...
Marshall Morrise's user avatar
0 votes
0 answers
187 views

Render a controller template from a custom module in a theme page

I have created a custom module whose routes are defined as follows. bigdeal_infos.infos_controller_infosScreen: path: '/bigdeal_infos/infos' defaults: _controller: '\Drupal\bigdeal_infos\...
Muhammad Tashfeen's user avatar
0 votes
0 answers
240 views

Block not showing in controller generated tables Drupal 8

I have created a custom module that should show my custom block above the controller generated table. The block shows in other pages but not in the page where it is supposed to show. Found out that it ...
ylleigh12's user avatar
0 votes
1 answer
961 views

How can I customize the header and footer from a custom page controller?

I have a module named some_module. This is my some_module.routing.yml: some_module.index: path: '/this/is/the/path' defaults: _title: 'Some Title' _controller: '\Drupal\some_module\...
aceraven777's user avatar
3 votes
1 answer
599 views

Using OAuth2 on non-REST endpoints

I have a custom module which includes a ControllerBase. The controller has a content() function that returns a JsonResponse(). The code for this function returns a complete list of a certain entity ...
saramm1's user avatar
  • 727
5 votes
1 answer
582 views

How to deal with Bubbleable Metadata when there's no rendering context and no render array

Since Drupal 8.0.0-beta12 "all rendering must happen in a render context", as stated by this change record. This is to avoid bubbleable metadata lost. So far, so good. Let's say I'm implementing a ...
sanzante's user avatar
  • 6,981
1 vote
2 answers
2k views

How to programmatically build a page and a form in the same page

What I'd like to do is build a page with two things: On one half of the page, custom markup with data from Drupal. On the other half, a custom form also submitted to Drupal. There are a lot of ...
Joseph's user avatar
  • 1,596
0 votes
0 answers
176 views

Format Json Responses as Camel Case

Currently our json responses are not formatted at all, we are using the JsonResponse class to return a status code with content: public function getMarkets() { $response = $this->...
The Pax Bisonica's user avatar
0 votes
1 answer
958 views

Why isn't my controller returning AccessResult::forbidden()?

I'm working on a node access module. I've set up my logic. I can't seem to get my code to return AccessResult::forbidden(). I can't even get \dpm to run in access method. What am I doing wrong? Below ...
Kartagis's user avatar
  • 612
5 votes
1 answer
3k views

Is there a "best practice" for overriding a contributed module's controller?

I'm still relatively new to Drupal 8 and recently I came across an occasion to override the WebFormSubmissionListBuilder Controller. I eventually found another project which had exactly the same need ...
user5429087's user avatar
0 votes
1 answer
72 views

Permission denied for a route implemented by a custom module [closed]

Hello I have the same problem with the following code: first_module.routing.yml: first_module.content: path: '/first' defaults: _controller: 'Drupal\first_module\Controller\FirstController::...
Emilio's user avatar
  • 1
0 votes
1 answer
659 views

Pass argument when overriding controller in RouteSubscriber

I am having the issue of overriding the default taxonomy controller /taxonomy/term/{tid}. I have created my own controller which takes {tid} as a parameter and I want to use it instead, so I overrode ...
JetSet's user avatar
  • 147
0 votes
0 answers
416 views

How can I use a controller to render a form in a template file?

I'm looking to add a form inside a custom template. opacsearchmodule.routing.yml opacsearchmodule.route1: path: '/form-test/object-builder' defaults: _form: '\Drupal\opacsearchmodule\Form\...
Duha Shawareb's user avatar
1 vote
1 answer
1k views

Creating a table with pagination in a Node Edit form

I have a content type article that has a field for Category. In order to help our editors find related articles, I included a table on the article Edit page that pulls in other article entities that ...
The Unknown Dev's user avatar
0 votes
1 answer
361 views

Instantiate Controller with Interface not concrete class [closed]

As background, I am rebuilding some old code and want to wrap all the curl based requests in an interface (HttpRequestInterface) so I can swap that out later without having to write all the api calls ...
Rob Allen's user avatar
  • 103
0 votes
1 answer
65 views

Inject variables from Controller to Blocks?

I have a Product module that implement's an entity, a Repository, a Controller and 2 Blocks The problem is, in the product page, I'm querying the entity in every block and also in the Controller. I'm ...
Juan Miret's user avatar
0 votes
1 answer
196 views

Render page with theme wrapper from custom controller?

I've created a page layout using panels in the Drupal admin UI (page_machine_id). I'm trying to load that page into a custom controller like so and render one of the variants (Drupal 8): public ...
iamamused's user avatar
  • 101