You are here

class MandrillActivityRoutes in Mandrill 8

Defines dynamic routes for Mandrill Activity entities.

This allows Mandrill activity to be displayed on any entity.

Hierarchy

Expanded class hierarchy of MandrillActivityRoutes

File

modules/mandrill_activity/src/Routing/MandrillActivityRoutes.php, line 18
Contains \Drupal\mandrill_activity\Routing\MandrillActivityRoutes.

Namespace

Drupal\mandrill_activity\Routing
View source
class MandrillActivityRoutes {

  /**
   * {@inheritdoc}
   */
  public function routes() {
    $routes = array();
    $activity_ids = \Drupal::entityQuery('mandrill_activity')
      ->execute();
    $activity_entities = MandrillActivity::loadMultiple($activity_ids);

    /* @var $activity \Drupal\mandrill_activity\Entity\MandrillActivity */
    foreach ($activity_entities as $activity) {
      if (!$activity->enabled) {
        continue;
      }
      $routes['entity.' . $activity->entity_type . '.mandrill_activity'] = new Route($activity->entity_type . '/{' . $activity->entity_type . '}/mandrill_activity', array(
        '_controller' => '\\Drupal\\mandrill_activity\\Controller\\MandrillActivityController::overview',
        '_title' => 'Mandrill Activity',
      ), array(
        '_permission' => 'access mandrill activity',
      ));
    }
    return $routes;
  }

}

Members