summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
blob: d3ca362624ef69c34e9929bec0eef1313b1a4253 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

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

namespace Drupal\entity_test\Routing;

use Symfony\Component\Routing\Route;

/**
 * Subscriber for Entity Test routes.
 */
class EntityTestRoutes {

  /**
   * Returns an array of route objects.
   *
   * @return \Symfony\Component\Routing\Route[]
   *   An array of route objects.
   */
  public function routes() {
    $types = entity_test_entity_types();
    $types[] = 'entity_test_string_id';
    $types[] = 'entity_test_no_id';

    $routes = array();
    foreach ($types as $entity_type_id) {
      $routes["entity.$entity_type_id.add_form"] = new Route(
        "$entity_type_id/add",
        array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdd', 'entity_type_id' => $entity_type_id),
        array('_permission' => 'administer entity_test content')
      );

      $routes["entity.$entity_type_id.edit_form"] = new Route(
        "$entity_type_id/manage/{" . $entity_type_id . '}',
        array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id),
        array('_permission' => 'administer entity_test content'),
        array('parameters' => array(
          $entity_type_id => array('type' => 'entity:' . $entity_type_id),
        ))
      );

      $routes["entity.$entity_type_id.admin_form"] = new Route(
        "$entity_type_id/structure/{bundle}",
        array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'),
        array('_permission' => 'administer entity_test content')
      );
    }
    return $routes;
  }

}