Pregunta

How do i get the workflow entity associated to a certain node bundle? So far my approach has been to use EntityTypeManager to load the workflow config entity storage and trying to load the right workflow using loadByProperties() function,

$workflow = $this->entityTypeManager->getStorage('workflow')->loadByProperties();

except I don't know what properties I should be specifying or If I'm approaching this the right way.

¿Fue útil?

Solución

Workflows are configuration entities so you can load them using their id:

$workflow = $this->entityTypeManager->getStorage('workflow')->load('workflow_machine_name');

Or "query" them using the Entity Query (check the Drupal 8 example shown here):

$query = $this->entityTypeManager->getStorage('workflow')->getQuery();
$query->condition('type_settings.entity_types.node', 'article', 'IN');
$workflows = $query->execute();

The condition is a proof-of-concept drawn from another config entity query but is the right path you need to test it agains the workflow entity schema.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a drupal.stackexchange
scroll top