migration is ok again (remains probleme of ram consuming > 4Go for users
This commit is contained in:
@@ -7,13 +7,13 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
|
||||
// ksm($fields);
|
||||
// ksm($delta);
|
||||
$famille = $entity->get('field_famille')->getValue()[0]['value'];
|
||||
|
||||
|
||||
// $entity->isNew(); ??
|
||||
// TODO: what if familly change ?
|
||||
if (!empty($entity->field_index->value)) { // the node is not new
|
||||
return $entity->field_index->value;
|
||||
}
|
||||
|
||||
|
||||
// the node is new
|
||||
// get all same entities in same family
|
||||
$query = \Drupal::entityQuery($entity->getEntityTypeId())
|
||||
@@ -21,17 +21,22 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
|
||||
->condition('field_famille', $famille)
|
||||
->sort('field_index', 'DESC')
|
||||
->range(0,1);
|
||||
|
||||
|
||||
$nids = $query->execute();
|
||||
|
||||
|
||||
$index = null;
|
||||
if(is_array($nids)){
|
||||
$last = entity_load($entity->getEntityTypeId(), array_pop($nids));
|
||||
// get identifiants fo these entities
|
||||
$index = $last->get('field_index')->getValue()[0]['value'] + 1;
|
||||
}else{
|
||||
$index = '1';
|
||||
$nid = array_pop($nids);
|
||||
if ($nid) {
|
||||
$last = entity_load($entity->getEntityTypeId(), array_pop($nids));
|
||||
// get identifiants fo these entities
|
||||
$index = $last->get('field_index')->getValue()[0]['value'] + 1;
|
||||
}
|
||||
}
|
||||
return $index;
|
||||
// if(!$index){
|
||||
// $index = '1';
|
||||
// }
|
||||
return $index ? $index : '1';
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +74,7 @@ function materio_id_form_node_materiau_edit_form_alter(&$form, \Drupal\Core\Form
|
||||
// dsm($family);
|
||||
$form['field_famille']['widget']['#disabled'] = true;
|
||||
}
|
||||
|
||||
|
||||
// adding reference to the form title
|
||||
$ref = $node->field_reference->value;
|
||||
// dsm($ref);
|
||||
|
Reference in New Issue
Block a user