public function EntityManager::getAdminPath

Returns the administration path for an entity type's bundle.

Parameters

string $entity_type: The entity type.

string $bundle: The name of the bundle.

Return value

string The administration path for an entity type bundle, if it exists.

File

drupal/core/lib/Drupal/Core/Entity/EntityManager.php, line 252
Contains \Drupal\Core\Entity\EntityManager.

Class

EntityManager
Manages entity type plugin definitions.

Namespace

Drupal\Core\Entity

Code

public function getAdminPath($entity_type, $bundle) {
  $admin_path = '';
  $entity_info = $this
    ->getDefinition($entity_type);

  // Check for an entity type's admin base path.
  if (isset($entity_info['route_base_path'])) {

    // If the entity type has a bundle prefix, strip it out of the path.
    if (isset($entity_info['bundle_prefix'])) {
      $bundle = str_replace($entity_info['bundle_prefix'], '', $bundle);
    }

    // Replace any dynamic 'bundle' portion of the path with the actual bundle.
    $admin_path = str_replace('{bundle}', $bundle, $entity_info['route_base_path']);
  }
  return $admin_path;
}