Active
Project:
node_clone
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2014 at 22:05 UTC
Updated:
2 Mar 2014 at 12:13 UTC
Jump to comment: Most recent
I've updated this change record page today: https://drupal.org/node/2196275. It describes that hook_entity_type_build() should be used to add definitions, not the alter hook.
/**
* Implements hook_entity_type_build().
*/
function node_clone_entity_type_build($entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
// Add a form controller for clone operations.
$classes = $entity_types['node']->getControllerClasses();
$form_classes = $classes['form'] + array('clone' => 'Drupal\node_clone\NodeCloneFormController');
$entity_types['node']->setControllerClass('form', $form_classes);
}
This is how I added an entity clone form controller.
node_clone.clone:
path: 'node/{node}/clone'
defaults:
_entity_form: 'node.clone'
requirements:
_permission: 'node clone node'
And this is how it is used in node_clone.routing.yml.
Comments
Comment #1
franskuipers commentedAgreed.
In \Drupal\Core\Entity\EntityTypeInterface i find this documentation:
Apparently hook_entity_type_alter() is only to alter existing properties?