EntityTestRoutes.php 1.56 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php

/**
 * @file
 * Contains \Drupal\entity_test\Routing\RouteSubscriber.
 */

namespace Drupal\entity_test\Routing;

use Symfony\Component\Routing\Route;

/**
 * Subscriber for Entity Test routes.
 */
15
class EntityTestRoutes {
16 17

  /**
18 19 20 21
   * Returns an array of route objects.
   *
   * @return \Symfony\Component\Routing\Route[]
   *   An array of route objects.
22
   */
23
  public function routes() {
24
    $types = entity_test_entity_types();
25
    $types[] = 'entity_test_string_id';
26
    $types[] = 'entity_test_no_id';
27

28
    $routes = array();
29
    foreach ($types as $entity_type) {
30
      $routes["entity_test.add_$entity_type"] = new Route(
31 32 33 34 35
        "$entity_type/add",
        array('_content' => '\Drupal\entity_test\Controller\EntityTestController::testAdd', 'entity_type' => $entity_type),
        array('_permission' => 'administer entity_test content')
      );

36
      $routes["entity_test.edit_$entity_type"] = new Route(
37 38
        "$entity_type/manage/{" . $entity_type . '}',
        array('_content' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', '_entity_type' => $entity_type),
39 40 41 42 43
        array('_permission' => 'administer entity_test content'),
        array('parameters' => array(
          'entity' => array('type' => 'entity:' . $entity_type),
        ))
      );
44

45
      $routes["entity_test.admin_$entity_type"] = new Route(
46 47 48 49
        "$entity_type/structure/{bundle}",
        array('_content' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'),
        array('_permission' => 'administer entity_test content')
      );
50
    }
51
    return $routes;
52 53 54
  }

}