Questions tagged [page-controller]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
85 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 ...
0
votes
2answers
53 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 ...
0
votes
0answers
47 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 ...
1
vote
1answer
31 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' ...
-2
votes
1answer
25 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' => '...
0
votes
1answer
24 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 ...
0
votes
1answer
25 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 ...
1
vote
1answer
63 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\...
0
votes
1answer
63 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 ...
1
vote
0answers
80 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 ...
0
votes
1answer
60 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 ...
0
votes
1answer
81 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 ...
0
votes
1answer
192 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 ...
1
vote
1answer
65 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 ...
0
votes
1answer
896 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 ...
0
votes
1answer
50 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'...
1
vote
1answer
83 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 ...
-1
votes
1answer
104 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. ...
0
votes
0answers
91 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 ...
0
votes
0answers
71 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 ...
0
votes
2answers
50 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\...
0
votes
1answer
162 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' ...
0
votes
0answers
57 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\...
0
votes
0answers
195 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 ...
0
votes
1answer
312 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\...
3
votes
1answer
351 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 ...
5
votes
1answer
341 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 ...
1
vote
2answers
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 ...
0
votes
0answers
90 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->...
0
votes
1answer
431 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 ...
0
votes
1answer
36 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::...
0
votes
1answer
403 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 ...
0
votes
0answers
218 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\...
1
vote
1answer
672 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 ...
0
votes
1answer
263 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 ...
0
votes
1answer
45 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 ...
0
votes
1answer
126 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 ...
0
votes
0answers
69 views

Assign a controller to all book pages

I am trying to build a module that checks if user session set in all pages of a certain book. if the session is not set it will be set. I am using a sso system so the user data will come from there, ...
-2
votes
1answer
333 views

Page not found error when creating a simple module [closed]

I have my first module in drupal 8 with three files in modules section of my drupal: hello_world.routing.yml: hello_world: path: '/hello/world' defaults: _controller: '\Drupal\...
1
vote
1answer
2k views

Creating iframe to be used in other websites

I've created a controller with the route "/get-info", the controller return a template custom-info.html.twig my_module/src/Controller/MyController.php file: <?php namespace Drupal\my_module\...
2
votes
1answer
2k views

How to send formatted html email using swiftmailer?

How can I send styled html body using custom module to send an email. I am using swiftmailer module. With that I am able to send normal body, but I am not able to use html tags or css. How can I do ...
-1
votes
2answers
188 views

How do I pass a CSS class to the controller? [closed]

I want to pass a CSS class to a controller. In the case of nodes, I am using the following code. $node = \Drupal::routeMatch()->getParameter('node'); if ($node) { $variables['attributes']['...
-2
votes
1answer
3k views

How to create a dynamic front page [closed]

I have created page--front.html in drupal 8 custom theme then how to make dynamic this page section ? where I write custom code. i.e. how to showing slider images to which is added in admin side. ...
0
votes
1answer
43 views

How to set a url in drupal database or settings.php?

I had created a controller in custom module using drupal 8. public function subscribe(Request $request) { $url='https://username:password@someurl.com/v1/subscriptions'; } I am using git ...
4
votes
2answers
6k views

How to check whether a username already exists?

I had created a controller where I can create a new user programmitically by the following code. $user = User::create(); //Mandatory settings $user->setPassword($password); $...
3
votes
1answer
1k views

Edit a config variable of a custom module in controller

Is it possible to edit/create a config variable of a module in a controller created in the same module? For example: module_name/src/Controller/MyController.php: class MyController extends ...
0
votes
1answer
50 views

module controller does not respond!

I'm trying to create a controller within my custom module, but the controller still doesn't response when visiting the associated path. Here are my files: my_module/my_module.routing.yml: my_module....
0
votes
3answers
2k views

How to change payment state programmatically?

I had created a custom module to update order state and payment state. In my controller I used the following code to change the order state of order. $order = \Drupal\commerce_order\Entity\Order::...
2
votes
1answer
1k views

How to attach a library to a page controller that returns a plain Symfony response?

I created a custom module with a page controller that returns a Symfony response (Symfony\Component\HttpFoundation\Response). The thing is I don't want to render my custom theme in this controller, ...
0
votes
1answer
5k views

Get variable from controller in twig using template

I have a php variable in my controller and i want to use it in twig. So i do this : Controller : $firstLetter = '2017'; //dynamic variable but for the test it's a constant $build ['list'] = ...