function auto_entitylabel_entity_presave in Automatic Entity Label 8
Same name and namespace in other branches
- 8.3 auto_entitylabel.module \auto_entitylabel_entity_presave()
- 8.2 auto_entitylabel.module \auto_entitylabel_entity_presave()
- 7 auto_entitylabel.module \auto_entitylabel_entity_presave()
Implements hook_entity_presave().
File
- ./
auto_entitylabel.module, line 101 - Allows hiding of entity label fields and automatic label creation.
Code
function auto_entitylabel_entity_presave(EntityInterface $entity) {
if ($entity instanceof ContentEntityInterface) {
$decorator = \Drupal::service('auto_entitylabel.entity_decorator');
/** @var \Drupal\auto_entitylabel\AutoEntityLabelManager $decorated_entity */
$decorated_entity = $decorator
->decorate($entity);
if ($decorated_entity
->hasLabel() && $decorated_entity
->autoLabelNeeded()) {
$decorated_entity
->setLabel();
}
}
}