diff -u b/auto_entitylabel.module b/auto_entitylabel.module --- b/auto_entitylabel.module +++ b/auto_entitylabel.module @@ -47,15 +47,15 @@ function auto_entitylabel_form_alter(&$form, FormStateInterface $form_state) { if (isset($form['#entity_builders']) && empty($form['#auto_entitylabel_processed'])) { $decorator = \Drupal::service('auto_entitylabel.entity_decorator'); - if ($form_state->getFormObject()->getEntity() instanceof ContentEntityInterface) { - /** @var \Drupal\auto_entitylabel\AutoEntityLabelManager $entity */ - $entity = $decorator->decorate($form_state->getFormObject()->getEntity()); + /** @var \Drupal\auto_entitylabel\AutoEntityLabelManager $entity */ + $entity = $decorator->decorate($form_state->getFormObject()->getEntity()); + if ($entity instanceof ContentEntityInterface) { if ($entity->hasAutoLabel()) { $label = $entity->getLabelName(); $widget = &$form[$label]['widget'][0]; - // Hide the label field. t will be automatically generated - // in hook_entity_presave(). + // Hide the label field. It will be automatically generated in + // hook_entity_presave(). $widget['value']['#type'] = 'hidden'; $widget['value']['#required'] = FALSE; if (empty($widget['value']['#default_value'])) { @@ -71,9 +71,9 @@ $widget['value']['#required'] = FALSE; } } - } - $form['#auto_entitylabel_processed'] = TRUE; + $form['#auto_entitylabel_processed'] = TRUE; + } } } only in patch2: unchanged: --- a/auto_entitylabel.permissions.yml +++ b/auto_entitylabel.permissions.yml @@ -1,2 +1,2 @@ permission_callbacks: - - Drupal\auto_entitylabel\AutoEntityLabelPermisssionController::autoEntityLabelPermissions \ No newline at end of file + - Drupal\auto_entitylabel\AutoEntityLabelPermissionController::autoEntityLabelPermissions only in patch2: unchanged: --- a/auto_entitylabel.services.yml +++ b/auto_entitylabel.services.yml @@ -10,4 +10,8 @@ services: tags: - { name: route_enhancer } auto_entitylabel.manager: - class: Drupal\auto_entitylabel\AutoEntityLabelManager \ No newline at end of file + class: Drupal\auto_entitylabel\AutoEntityLabelManager + arguments: ['@entity.manager', '@config.factory', '@entity_type.manager', '@token'] + auto_entitylabel.entity_decorator: + class: Drupal\auto_entitylabel\EntityDecorator + arguments: ['@config.factory', '@entity_type.manager', '@token'] only in patch2: unchanged: --- /dev/null +++ b/src/AutoEntityLabelManagerInterface.php @@ -0,0 +1,49 @@ +