Skip to main content
added 137 characters in body
Source Link
NicklasF
  • 329
  • 4
  • 14

Here is a patch that addsYou can extend the entity with a custom entity alter forclass and set it as the label: https://www.drupal.org/project/paragraphs/issues/2900538class to use for that entity type.

The attached patch will allow developers to implement hook_paragraph_label_alter().

It can then be usedExtend the Paragraph entity class and override the label() method like this:

functionclass hook_paragraph_label_alter(stringParagraphExt &$label,extends Paragraph $paragraph{
  function label() { 
  $label = "Thisreturn is"your alabel";
 new label";}
}

Then set it as the class to use in hook_entity_type_alter like:

function hook_entity_type_alter(array &$entity_types) {
  $entity_types['paragraph']->setClass(ParagraphExt::class);
}

Here is a patch that adds a custom entity alter for the label: https://www.drupal.org/project/paragraphs/issues/2900538

The attached patch will allow developers to implement hook_paragraph_label_alter().

It can then be used like

function hook_paragraph_label_alter(string &$label, Paragraph $paragraph) { 
  $label = "This is a new label";
}

You can extend the entity with a custom class and set it as the class to use for that entity type.

Extend the Paragraph entity class and override the label() method like this:

class ParagraphExt extends Paragraph {
  function label() {
    return "your label";
  }
}

Then set it as the class to use in hook_entity_type_alter like:

function hook_entity_type_alter(array &$entity_types) {
  $entity_types['paragraph']->setClass(ParagraphExt::class);
}
Source Link
NicklasF
  • 329
  • 4
  • 14

Here is a patch that adds a custom entity alter for the label: https://www.drupal.org/project/paragraphs/issues/2900538

The attached patch will allow developers to implement hook_paragraph_label_alter().

It can then be used like

function hook_paragraph_label_alter(string &$label, Paragraph $paragraph) { 
  $label = "This is a new label";
}