You are here

NodeEntityHierarchyHandler.php in Entity Reference Hierarchy 3.x

Same filename and directory in other branches
  1. 8.2 src/Handler/NodeEntityHierarchyHandler.php

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;

/**
 * Defines a class for entity hierarchy implementations for node module.
 */
class NodeEntityHierarchyHandler implements EntityHierarchyHandlerInterface {

  /**
   * {@inheritdoc}
   */
  public function getAddChildUrl(EntityTypeInterface $entityType, ContentEntityInterface $parent, $bundle, $fieldName) {
    return Url::fromRoute('node.add', [
      'node_type' => $bundle,
    ], [
      'query' => [
        $fieldName => $parent
          ->id(),
      ],
    ]);
  }

}

Classes

Namesort descending Description
NodeEntityHierarchyHandler Defines a class for entity hierarchy implementations for node module.