You are here

protected function GroupContentMenu::urlRouteParameters in Group Content Menu 8

Gets an array of placeholders for this entity.

Individual entity classes may override this method to add additional placeholders if desired. If so, they should be sure to replicate the property caching logic.

Parameters

string $rel: The link relationship type, for example: canonical or edit-form.

Return value

array An array of URI placeholders.

Overrides EntityBase::urlRouteParameters

File

src/Entity/GroupContentMenu.php, line 109

Class

GroupContentMenu
Defines the group content menu entity class.

Namespace

Drupal\group_content_menu\Entity

Code

protected function urlRouteParameters($rel) {
  $uri_route_parameters = parent::urlRouteParameters($rel);

  /** @var \Drupal\group\Entity\GroupContentInterface[] $group_contents */
  $group_contents = \Drupal::entityTypeManager()
    ->getStorage('group_content')
    ->loadByEntity($this);
  if ($group_content = reset($group_contents)) {

    // The group is needed as a route parameter.
    $uri_route_parameters['group'] = $group_content
      ->getGroup()
      ->id();
    $uri_route_parameters['group_content_menu_type'] = $group_content
      ->getEntity()
      ->bundle();
  }
  return $uri_route_parameters;
}