getInfo() fatal * (the flag tokens build t('@flag flag link', ['@flag' => $flag->label()])). * * Give every flag a string label: the related flagging collection name when * available, the flag ID as a fallback. */ function materio_flag_update_10200(&$sandbox = NULL) { $flags = \Drupal::service('flag')->getAllFlags(); $fixed = 0; foreach ($flags as $id => $flag) { $label = $flag->label(); if (is_string($label) && $label !== '') { continue; } $new_label = $id; if (preg_match('/^relflag_(\d+)_/', $id, $matches)) { $collection = \Drupal::entityTypeManager()->getStorage('flagging_collection')->load($matches[1]); if ($collection && is_string($collection->label()) && $collection->label() !== '') { $new_label = $collection->label(); } } $flag->set('label', $new_label)->save(); $fixed++; } return t('@count flag(s) with an empty label have been fixed.', ['@count' => $fixed]); }