fixed the create materials bugs from materio_id module

This commit is contained in:
2021-08-02 18:48:15 +02:00
parent 1fcf130b96
commit 12c77de231
3 changed files with 98 additions and 22 deletions

View File

@@ -16,6 +16,8 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
// the node is new
// get all same entities in same family
$bundle = $entity->bundle();
$entity_type_id = $entity->getEntityTypeId();
$query = \Drupal::entityQuery($entity->getEntityTypeId())
->condition('type', $entity->bundle())
->condition('field_famille', $famille)
@@ -28,7 +30,7 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
if(is_array($nids)){
$nid = array_pop($nids);
if ($nid) {
$last = entity_load($entity->getEntityTypeId(), array_pop($nids));
$last = entity_load($entity->getEntityTypeId(), $nid); // array_pop($nids)
// get identifiants fo these entities
$index = $last->get('field_index')->getValue()[0]['value'] + 1;
}