public function EntityHierarchyHandler::getAddChildUrl in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 src/Handler/EntityHierarchyHandler.php \Drupal\entity_hierarchy\Handler\EntityHierarchyHandler::getAddChildUrl()
Gets an add child URL.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entityType: Entity type.
\Drupal\Core\Entity\ContentEntityInterface $parent: Parent entity.
string $bundle: Child bundle.
string $fieldName: Child field name.
Return value
\Drupal\Core\Url Url to add new child.
Overrides EntityHierarchyHandlerInterface::getAddChildUrl
File
- src/
Handler/ EntityHierarchyHandler.php, line 17
Class
- EntityHierarchyHandler
- Defines a class for provide entity-type specific entity hierarchy logic.
Namespace
Drupal\entity_hierarchy\HandlerCode
public function getAddChildUrl(EntityTypeInterface $entityType, ContentEntityInterface $parent, $bundle, $fieldName) {
$routeName = "entity.{$entityType->id()}.add_form";
return Url::fromRoute($routeName, [
$entityType
->getKey('bundle') => $bundle,
], [
'query' => [
$fieldName => $parent
->id(),
],
]);
}