0

I am using the message module, so I have an entity of type 'message', as for the children I can get the machine name or the Uuid.

The problem I have is that by means of a 'hook_update_n' I need to update a field. The code I am using is:

function hook_update_8001() {

  //Change content in text field for 'caregiver_referral_incomplete'.
  $field_value = array(array('value' => 'Hello My formatted text', 'format' => 'basic_html'));

  entity_load('message', 2166)->getTemplate()->set('text', $field_value)->save();
}

With this structure, I need the Mid, but I only have the machine name or the Uuid, some way to find it with that data?

1

If you want to load by uuid, you can use this:

\Drupal::service('entity.repository')->loadEntityByUuid($entity_type_id, $uuid);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.