You are here

class AppRouteEnhancer in Apigee Edge 8

Route enhancer for team apps.

Sets "_entity" on app routes that contain app names ({app}) instead of app ids ({developer_app} or {team_app}). EntityRouteEnhancer can not do this because it expects that route parameter's name matches with the name of the entity type.

Hierarchy

Expanded class hierarchy of AppRouteEnhancer

See also

\Drupal\Core\Entity\Enhancer\EntityRouteEnhancer

1 string reference to 'AppRouteEnhancer'
apigee_edge.services.yml in ./apigee_edge.services.yml
apigee_edge.services.yml
1 service uses AppRouteEnhancer
route_enhancer.entity.app in ./apigee_edge.services.yml
Drupal\apigee_edge\Entity\Enhancer\AppRouteEnhancer

File

src/Entity/Enhancer/AppRouteEnhancer.php, line 37

Namespace

Drupal\apigee_edge\Entity\Enhancer
View source
class AppRouteEnhancer implements EnhancerInterface {

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {

    // The {app} route parameter gets up-casted to an app entity
    // by app by name converters. For example: DeveloperAppNameConverter.
    // @see \Drupal\apigee_edge\ParamConverter\DeveloperAppNameConverter
    if (!isset($defaults['_entity']) && isset($defaults['app']) && is_object($defaults['app']) && $defaults['app'] instanceof AppInterface) {

      // Required by entity view controllers and title callbacks for example.
      // @see \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhanceEntityView()
      // @see \Drupal\Core\Entity\Controller\EntityViewController::view()
      // @see \Drupal\Core\Entity\Controller\EntityController::doGetEntity()
      $defaults['_entity'] =& $defaults['app'];
    }
    return $defaults;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AppRouteEnhancer::enhance public function Update the defaults based on its own data and the request.