public function NodeEntityHierarchyHandler::getAddChildUrl in Entity Reference Hierarchy 8.2
Same name and namespace in other branches
- 3.x src/Handler/NodeEntityHierarchyHandler.php \Drupal\entity_hierarchy\Handler\NodeEntityHierarchyHandler::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/ NodeEntityHierarchyHandler.php, line 17
Class
- NodeEntityHierarchyHandler
- Defines a class for entity hierarchy implementations for node module.
Namespace
Drupal\entity_hierarchy\HandlerCode
public function getAddChildUrl(EntityTypeInterface $entityType, ContentEntityInterface $parent, $bundle, $fieldName) {
return Url::fromRoute('node.add', [
'node_type' => $bundle,
], [
'query' => [
$fieldName => $parent
->id(),
],
]);
}