public function NestedSetNodeKeyFactory::fromEntity in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 src/Storage/NestedSetNodeKeyFactory.php \Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory::fromEntity()
Creates a new node from an entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: Entity to convert into nested set node.
Return value
\PNX\NestedSet\NodeKey New node.
File
- src/
Storage/ NestedSetNodeKeyFactory.php, line 22
Class
- NestedSetNodeKeyFactory
- Defines a class for turning Drupal entities into nested set nodes.
Namespace
Drupal\entity_hierarchy\StorageCode
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);
}