0

So I have two content types, organisation and room. I'm using pathauto on room so the path for a room is /meet/[organisation]/[room] (based on a field in the room content type linking to the organisation). So if the organisation is 'public' and the room is 'lounge' it would appear at /meet/public/lounge.

I've add local tasks so that an info tab appears on viewing content of type room. cil_meet.links.task.yml:

cil_meet.roominfo: 
      route_name: 'cil_meet.roominfo' 
      title: 'Info'
      weight: 101
      base_route: entity.node.canonical

I also want the path /join to be handled, using the cil_meet.room route

cil_meet.room:
  path: '/meet/{organisation}/{room}/join'
  defaults:
    _controller: '\Drupal\cil_meet\Controller\CILMeetController::meet'
  requirements:
    _role: 'authenticated'
cil_meet.roominfo: 
#  path: '/meet/{organisation}/{room}/info'
#  defaults:
#    _controller: '\Drupal\cil_meet\Controller\CILMeetController::info'
  requirements:
    _role: 'authenticated'

With the above the lines commented out, /meet/{organisation}/{room} (the node view) and /meet/{organisation}/{room}/join work fine and the node view has the 'info' tab (with the path to site root). As soon as I introduce the path and defaults for cil_meet.roominfo by uncommenting those lines I get the following on /meet/{organisation}/{room}:

The website encountered an unexpected error. Please try again later.

/meet/{organisation}/{room}/join works fine, /meet/{organisation}/{room}/info works fine.

I get the following in the log:

Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("organisation", "room") to generate a URL for route "cil_meet.roominfo". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 182 of /srv/bindings/470553379ccd42bf8de4c6b45cd0f0c5/code/core/lib/Drupal/Core/Routing/UrlGenerator.php).

src/CILMeetController.php is:

<?php
namespace Drupal\cil_meet\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * Provides route responses to CIL Meet for the CIL module.
 */
class CILMeetController extends ControllerBase {

  /**
   * Returns a markup for room info.
   *
   * @return array
   *   A renderable array
   */
  public function info($organisation, $room) {
        $element = array(
      '#children' => "Info on $organisation/$room",
        '#cache' => ['max-age' => 0],    //don't cache.
        );

    return $element;
    }

      /**
   * Returns a markup when joining a room.
   *
   * @return array
   *   A renderable array
   */
  public function meet($organisation, $room) {  
        $element = array(
      '#children' => "Publish to $organisation/$room",
        '#cache' => ['max-age' => 0],    //don't cache.
        );

    return $element;
    }
}

The error message implies I've not included the $organisation and $room parameters, but they are there. Where am I going wrong?

  • drupal.stackexchange.com/questions/208480/… was helpful here. I disabled the pathauto pattern for the room content type (which generates the /meet/{organisation}/{room} path, and now get Access Denied on /meet/{organisation}/{room} - at least it's not WSD anymore. Probably just need to tweak my routing further now. – Matt B Apr 20 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.