NodeEntityHierarchyHandler.php in Entity Reference Hierarchy 8.2
File
src/Handler/NodeEntityHierarchyHandler.php
View source
<?php
namespace Drupal\entity_hierarchy\Handler;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
class NodeEntityHierarchyHandler implements EntityHierarchyHandlerInterface {
public function getAddChildUrl(EntityTypeInterface $entityType, ContentEntityInterface $parent, $bundle, $fieldName) {
return Url::fromRoute('node.add', [
'node_type' => $bundle,
], [
'query' => [
$fieldName => $parent
->id(),
],
]);
}
}