protected function EntityOperations::getDefaultLoadStateId in Workbench Moderation 8.2
Same name and namespace in other branches
- 8 src/EntityOperations.php \Drupal\workbench_moderation\EntityOperations::getDefaultLoadStateId()
Determines the default moderation state on load for an entity.
This method is only applicable when an entity is loaded that has no moderation state on it, but should. In those cases, failing to set one may result in NULL references elsewhere when other code tries to check the moderation state of the entity.
The amount of indirection here makes performance a concern, but given how Entity API works I don't know how else to do it. This reliably gets us *A* valid state. However, that state may be not the ideal one. Suggestions on how to better select the default state here are welcome.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity for which we want a default state.
Return value
string The default state for the given entity.
1 call to EntityOperations::getDefaultLoadStateId()
- EntityOperations::entityStorageLoad in src/
EntityOperations.php - Hook bridge.
File
- src/
EntityOperations.php, line 123
Class
- EntityOperations
- Defines a class for reacting to entity events.
Namespace
Drupal\workbench_moderationCode
protected function getDefaultLoadStateId(ContentEntityInterface $entity) {
return $this->moderationInfo
->loadBundleEntity($entity
->getEntityType()
->getBundleEntityType(), $entity
->bundle())
->getThirdPartySetting('workbench_moderation', 'default_moderation_state');
}