You are here

class NestedSetNodeKeyFactory in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Storage/NestedSetNodeKeyFactory.php \Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory

Defines a class for turning Drupal entities into nested set nodes.

Hierarchy

Expanded class hierarchy of NestedSetNodeKeyFactory

10 files declare their use of NestedSetNodeKeyFactory
ChildEntityWarningBuilder.php in src/Information/ChildEntityWarningBuilder.php
ChildOfMicrositeLookup.php in modules/entity_hierarchy_microsite/src/ChildOfMicrositeLookup.php
EntityHierarchy.php in src/Plugin/EntityReferenceSelection/EntityHierarchy.php
EntityHierarchy.php in modules/entity_hierarchy_workbench_access/src/Plugin/AccessControlHierarchy/EntityHierarchy.php
EntityHierarchyArgumentPluginBase.php in src/Plugin/views/argument/EntityHierarchyArgumentPluginBase.php

... See full list

1 string reference to 'NestedSetNodeKeyFactory'
entity_hierarchy.services.yml in ./entity_hierarchy.services.yml
entity_hierarchy.services.yml
1 service uses NestedSetNodeKeyFactory
entity_hierarchy.nested_set_node_factory in ./entity_hierarchy.services.yml
Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory

File

src/Storage/NestedSetNodeKeyFactory.php, line 11

Namespace

Drupal\entity_hierarchy\Storage
View source
class NestedSetNodeKeyFactory {

  /**
   * Creates a new node from an entity.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $entity
   *   Entity to convert into nested set node.
   *
   * @return \PNX\NestedSet\NodeKey
   *   New node.
   */
  public function fromEntity(ContentEntityInterface $entity) {
    $id = $entity
      ->id();
    if (!($revision_id = $entity
      ->getRevisionId())) {
      if (!($revision_id = $entity
        ->getLoadedRevisionId())) {
        $revision_id = $id;
      }
    }
    return new NodeKey($id, $revision_id);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NestedSetNodeKeyFactory::fromEntity public function Creates a new node from an entity.