0

I am currently using below code to generate routes:

foreach($this->hardcopyEntityManager->getHardcopyEntities() as $entity_type => $entity_definition)
 {

      $route = new Route(

        "/$entity_type/{entity}/hardcopy/{hardcopy_format}",

        array(
          '_controller' => 'Drupal\hardcopy\Controller\HardcopyController::showFormat',
          '_title' => 'Hardcopy',
        ),

        array(
          '_permission' => 'view printer friendly versions',
        ),

        array(
          'parameters' => array(
            'entity' => array('type' => 'entity:' . $entity_type),
          ),
        )
      );

      $collection->add('hardcopy.show_format.' . $entity_type, $route);
    }

But if now I want to make the same route using *.routing.yml file then how will I be proceeding? Assuming the entity type to be node.

2
  • The docs are pretty clear, which part you stuck at specifically? Can you post the contents of your routing file so far and point out which bit isn't working/you don't know how to continue with?
    – Clive
    Commented May 14, 2015 at 11:47
  • I am confused how to implement this part: array( 'parameters' => array( 'entity' => array('type' => 'entity:' . $entity_type), ), ) . I am not sure how to do this.Thanks Commented May 14, 2015 at 11:53

1 Answer 1

0
# This should be entity.node.hardcopy, also altering node link templates could be good idea
hardcopy.show_format.node:
  path: '/node/{node}/hardcopy/{hardcopy_format}'
  defaults:
    _controller: 'Drupal\hardcopy\Controller\HardcopyController::showFormat'
    _title: 'Hardcopy'
  requirements:
    _permission: 'view printer friendly versions'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.