The Entity reference module provides a auto complete field widget and this has been changed to a Form API element as 'entity_autocomplete'. This can be used in normal custom forms. Form element type can be used as 'entity_autocomplete' for entity reference fields. Following is a sample code structure to create a entity reference fields with in custom form.
Currently upon editing a node has workflow current state displayed on the node edit page. This information will not be available on node_load or entity load. Since the current workflow or content moderation state information will be on latest revision of that content. All just you need to do is to load the latest revision of the content.
In Drupal 8, The nodes are handled as the Entity. The core class Node is helping us to manage the operations of the Node. The below is the syntax and example for update the node details. The Node updates us happens with the Node id of the particular node.
To create a node which has a paragraph field you must create a Paragraph Item and respective object has to be referenced to the field. If this is a multiple add more field you can just loop this with the appendItem() for multiple items.
The following code will return the root path for a drupal file system. \Drupal::service('file_system')->realpath(file_default_scheme() . "://") . '/');
To enable revision and to log revision message on saving a node in drupal 8 we can use setNewRevision() and setRevisionLogMessage(). Find the below code which uses entity save with revision.
To load the author name or owner from a node entity object we can use getOwner(). The below example show how to load a node object using node id and to get the Author name from it.