class DeveloperAppRouteProvider in Apigee Edge 8
Default entity routes for developer apps.
Hierarchy
- class \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider implements EntityHandlerInterface, EntityRouteProviderInterface
- class \Drupal\apigee_edge\Entity\EdgeEntityRouteProvider
- class \Drupal\apigee_edge\Entity\AppRouteProvider
- class \Drupal\apigee_edge\Entity\DeveloperAppRouteProvider
- class \Drupal\apigee_edge\Entity\AppRouteProvider
- class \Drupal\apigee_edge\Entity\EdgeEntityRouteProvider
Expanded class hierarchy of DeveloperAppRouteProvider
File
- src/
Entity/ DeveloperAppRouteProvider.php, line 37
Namespace
Drupal\apigee_edge\EntityView source
class DeveloperAppRouteProvider extends AppRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type
->id();
if ($collection_by_developer = $this
->getCollectionRouteByDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.collection_by_developer", $collection_by_developer);
}
if ($canonical_by_developer = $this
->getCanonicalRouteByDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.canonical_by_developer", $canonical_by_developer);
}
if ($add_form_for_developer = $this
->getAddFormRouteForDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.add_form_for_developer", $add_form_for_developer);
}
if ($edit_form_for_developer = $this
->getEditFormRouteForDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.edit_form_for_developer", $edit_form_for_developer);
}
if ($delete_form_for_developer = $this
->getDeleteFormRouteForDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.delete_form_for_developer", $delete_form_for_developer);
}
if ($analytics_for_developer = $this
->getAnalyticsRouteForDeveloper($entity_type)) {
$collection
->add("entity.{$entity_type_id}.analytics_for_developer", $analytics_for_developer);
}
if ($api_keys = $this
->getApiKeyRouteDeveloperApp($entity_type)) {
$collection
->add("entity.{$entity_type_id}.api_keys", $api_keys);
}
if ($add_api_key_form = $this
->getAddApiKeyRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.add_api_key_form", $add_api_key_form);
}
if ($delete_api_key_form = $this
->getDeleteApiKeyRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.delete_api_key_form", $delete_api_key_form);
}
if ($revoke_api_key_form = $this
->getRevokeApiKeyRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.revoke_api_key_form", $revoke_api_key_form);
}
return $collection;
}
/**
* {@inheritdoc}
*/
protected function getAddFormRoute(EntityTypeInterface $entity_type) {
$route = parent::getAddFormRoute($entity_type);
if ($route) {
// We did not want to expose this UI to regular users this the reason
// why route is only available to admins for now.
$route
->setRequirement('_permission', 'administer developer_app');
}
return $route;
}
/**
* {@inheritdoc}
*/
protected function getCollectionRoute(EntityTypeInterface $entity_type) {
$route = parent::getCollectionRoute($entity_type);
if ($route) {
// Add "access developer_app overview" to the autogenerated permission
// requirement" (that contains "administer developer_app").
$route
->setRequirement('_permission', $route
->getRequirement('_permission') . '+access developer_app overview');
}
return $route;
}
/**
* Gets the add-form route for developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getAddFormRouteForDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('add-form-for-developer')) {
$route = new Route($entity_type
->getLinkTemplate('add-form-for-developer'));
$route
->setDefault('_entity_form', 'developer_app.add_for_developer');
$route
->setDefault('_title_callback', AppTitleProvider::class . '::addTitle');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_custom_access', AppsPageAccessCheck::class . '::createAppAccess');
return $route;
}
}
/**
* Gets the edit-form route for a developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getEditFormRouteForDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('edit-form-for-developer')) {
$route = new Route($entity_type
->getLinkTemplate('edit-form-for-developer'));
$route
->setDefault('_entity_form', 'developer_app.edit_for_developer');
$route
->setDefault('_title_callback', AppTitleProvider::class . '::editTitle');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'update');
// We must load the entity from Apigee Edge directly and omit cached
// version on edit forms.
$route
->setOption('apigee_edge_load_unchanged_entity', 'true');
return $route;
}
}
/**
* Gets the delete-form route for a developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getDeleteFormRouteForDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('delete-form-for-developer')) {
$route = new Route($entity_type
->getLinkTemplate('delete-form-for-developer'));
$route
->setDefault('_entity_form', 'developer_app.delete_for_developer');
$route
->setDefault('_title_callback', AppTitleProvider::class . '::deleteTitle');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'delete');
return $route;
}
}
/**
* Gets the canonical route for a developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getCanonicalRouteByDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('canonical-by-developer')) {
$route = new Route($entity_type
->getLinkTemplate('canonical-by-developer'));
$route
->setDefault('_controller', DeveloperAppViewControllerForDeveloper::class . '::view');
$route
->setDefault('_title_callback', AppTitleProvider::class . ':title');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'view');
return $route;
}
}
/**
* Gets the collection route for a developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getCollectionRouteByDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('collection-by-developer')) {
$route = new Route($entity_type
->getLinkTemplate('collection-by-developer'));
$route
->setDefault('_controller', DeveloperAppListBuilderForDeveloper::class . '::render');
$route
->setDefault('_title_callback', DeveloperAppListBuilderForDeveloper::class . '::pageTitle');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_custom_access', AppsPageAccessCheck::class . '::access');
return $route;
}
}
/**
* Gets the app analytics route for a developer.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getAnalyticsRouteForDeveloper(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('analytics-for-developer')) {
$route = new Route($entity_type
->getLinkTemplate('analytics-for-developer'));
$route
->setDefault('_form', DeveloperAppAnalyticsFormForDeveloper::class);
$route
->setDefault('_title_callback', AppTitleProvider::class . '::analyticsTitle');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'analytics');
return $route;
}
}
/**
* Gets the add-api-key-form route for a developer app.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getAddApiKeyRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('add-api-key-form')) {
$route = new Route($entity_type
->getLinkTemplate('add-api-key-form'));
$route
->setDefault('_form', DeveloperAppApiKeyAddForm::class);
$route
->setDefault('_title', 'Add key');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'add_api_key');
return $route;
}
}
/**
* Gets the delete-api-key-form route for a developer app.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getDeleteApiKeyRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('delete-api-key-form')) {
$route = new Route($entity_type
->getLinkTemplate('delete-api-key-form'));
$route
->setDefault('_form', DeveloperAppApiKeyDeleteForm::class);
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'delete_api_key');
return $route;
}
}
/**
* Gets the revoke-api-key-form route for a developer app.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevokeApiKeyRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('revoke-api-key-form')) {
$route = new Route($entity_type
->getLinkTemplate('revoke-api-key-form'));
$route
->setDefault('_form', DeveloperAppApiKeyRevokeForm::class);
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'revoke_api_key');
return $route;
}
}
/**
* If route contains the {user} parameter add required changes to the route.
*
* @param \Symfony\Component\Routing\Route $route
* The route to be checked and altered if needed.
*/
private function ensureUserParameter(Route $route) {
if (strpos($route
->getPath(), '{user}') !== FALSE) {
// Default validation criteria based on Drupal core paths.
$route
->setRequirement('user', '\\d+');
// Make sure the parameter gets up-casted.
// (This also ensures that we get an "Page not found" page if user with
// uid does not exist.)
$route
->setOption('parameters', [
'user' => [
'type' => 'entity:user',
'converter' => 'paramconverter.entity',
],
]);
}
}
/**
* Gets the api key route for a developer app.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getApiKeyRouteDeveloperApp(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('api-keys')) {
$route = new Route($entity_type
->getLinkTemplate('api-keys'));
$route
->setDefault('_controller', DeveloperAppKeysController::class . '::developerAppKeys');
$route
->setDefault('_title_callback', AppTitleProvider::class . '::title');
$route
->setDefault('entity_type_id', $entity_type
->id());
$this
->ensureUserParameter($route);
$route
->setRequirement('_app_access_check_by_app_name', 'view');
return $route;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AppRouteProvider:: |
protected | function | Gets the analytics route. | |
DefaultHtmlRouteProvider:: |
protected | property | The entity field manager. | |
DefaultHtmlRouteProvider:: |
protected | property | The entity type manager. | |
DefaultHtmlRouteProvider:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the add page route. | 2 |
DefaultHtmlRouteProvider:: |
protected | function | Returns the delete multiple form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the type of the ID key for a given entity type. | 1 |
DefaultHtmlRouteProvider:: |
public | function | Constructs a new DefaultHtmlRouteProvider. | 1 |
DeveloperAppRouteProvider:: |
private | function | If route contains the {user} parameter add required changes to the route. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the add-api-key-form route for a developer app. | |
DeveloperAppRouteProvider:: |
protected | function |
Gets the add-form route. Overrides DefaultHtmlRouteProvider:: |
|
DeveloperAppRouteProvider:: |
protected | function | Gets the add-form route for developer. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the app analytics route for a developer. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the api key route for a developer app. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the canonical route for a developer. | |
DeveloperAppRouteProvider:: |
protected | function |
Gets the collection route. Overrides DefaultHtmlRouteProvider:: |
|
DeveloperAppRouteProvider:: |
protected | function | Gets the collection route for a developer. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the delete-api-key-form route for a developer app. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the delete-form route for a developer. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the edit-form route for a developer. | |
DeveloperAppRouteProvider:: |
protected | function | Gets the revoke-api-key-form route for a developer app. | |
DeveloperAppRouteProvider:: |
public | function |
Provides routes for entities. Overrides AppRouteProvider:: |
|
EdgeEntityRouteProvider:: |
protected | function |
Gets the canonical route. Overrides DefaultHtmlRouteProvider:: |
1 |
EdgeEntityRouteProvider:: |
protected | function |
Gets the delete-form route. Overrides DefaultHtmlRouteProvider:: |
|
EdgeEntityRouteProvider:: |
protected | function |
Gets the edit-form route. Overrides DefaultHtmlRouteProvider:: |