/** * {@inheritdoc} */ public function getRoutes(EntityTypeInterface $entity_type) { $route_collection = parent::getRoutes($entity_type); if ($entity_type->hasLinkTemplate('collection')) { $route = (new Route($entity_type->getLinkTemplate('collection'))) ->addDefaults([ '_entity_list' => 'contact_message', '_title' => 'Contact messages', ]) ->addRequirements([ '_permission' => 'administer contact forms', ]); $route_collection->add('entity.' . $entity_type->id() . '.collection', $route); } if ($entity_type->hasLinkTemplate('clone-form')) { $route = (new Route($entity_type->getLinkTemplate('clone-form'))) ->addDefaults([ '_entity_form' => 'contact_form.clone', '_title' => 'Clone form', ]) ->addRequirements([ '_entity_access' => 'contact_form.clone', ]); $route_collection->add('entity.' . $entity_type->id() . '.clone_form', $route); } return $route_collection; }
/** * {@inheritdoc} */ public function getRoutes(EntityTypeInterface $entity_type) { $collection = parent::getRoutes($entity_type); /** @var \Drupal\profile\Entity\ProfileTypeInterface $profile_type */ foreach (ProfileType::loadMultiple() as $profile_type) { $route = new Route("/user/{user}/{profile_type}", ['_controller' => '\\Drupal\\profile\\Controller\\ProfileController::userProfileForm'], ['_profile_access_check' => 'add'], ['parameters' => ['user' => ['type' => 'entity:user'], 'profile_type' => ['type' => 'entity:profile_type']]]); $collection->add("entity.profile.type.{$profile_type->id()}.user_profile_form", $route); // If the profile type supports multiple, we need an additional route for // adding new profiles. if ($profile_type->getMultiple()) { $route = new Route("/user/{user}/{profile_type}/add", ['_controller' => '\\Drupal\\profile\\Controller\\ProfileController::addProfile'], ['_profile_access_check' => 'add'], ['parameters' => ['user' => ['type' => 'entity:user'], 'profile_type' => ['type' => 'entity:profile_type']]]); $collection->add("entity.profile.type.{$profile_type->id()}.user_profile_form.add", $route); } } return $collection; }
public function getRoutes(EntityTypeInterface $entity_type) { $collection = parent::getRoutes($entity_type); foreach ($this->entityManager->getStorage('profile_type')->loadMultiple() as $profile_type_id => $profile_type) { $route = new Route( "/user/{user}/edit/user_profile_form/{profile_type}", ['_controller' => '\Drupal\profile\Controller\ProfileController::userProfileForm'], ['_profile_access_check' => 'add'], ['parameters' => [ 'user' => ['type' => 'entity:user'], 'profile_type' => ['type' => 'entity:profile_type'], $profile_type_id => ['type' => 'profile:' . $profile_type_id], ]] ); $collection->add("entity.profile.type.$profile_type_id.user_profile_form", $route); } return $collection; }