You are here

public function RouteSubscriber::routes in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/RouteSubscriber.php \Drupal\entity_browser\RouteSubscriber::routes()

Returns a set of route objects.

Return value

\Symfony\Component\Routing\RouteCollection A route collection.

File

src/RouteSubscriber.php, line 46

Class

RouteSubscriber
Generates routes for entity browsers.

Namespace

Drupal\entity_browser

Code

public function routes() {
  $collection = new RouteCollection();
  foreach ($this
    ->getBrowserIDsWithRoute() as $id) {

    /** @var $browser \Drupal\entity_browser\EntityBrowserInterface */
    $browser = $this->browserStorage
      ->load($id);
    if ($route = $browser
      ->route()) {
      $collection
        ->add('entity_browser.' . $browser
        ->id(), $route);
    }
  }
  return $collection;
}