function entity_hierarchy_views_node_prepare_form in Entity Reference Hierarchy 8
Implements hook_ENTITY_TYPE_prepare_form().
Set a default embedded view.
File
- entity_hierarchy_views/
entity_hierarchy_views.module, line 185 - Contains entity_hierarchy_views.module..
Code
function entity_hierarchy_views_node_prepare_form(EntityInterface $node, $operation, FormStateInterface $form_state) {
$config = \Drupal::getContainer()
->get('config.factory')
->getEditable('entity_hierarchy.settings');
// Set the default children view if there is one for this type and if the node has not been saved yet.
if (empty($node
->id()) && empty($node->nh_children_view) && ($children_view = $config
->get('nh_default_children_view_' . $node
->getType()))) {
list($node->nh_children_view, $node->nh_children_view_display) = explode(':', $children_view);
}
}