function ContentModeration::getInitialState
Same name in other branches
- 9 core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::getInitialState()
- 8.9.x core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::getInitialState()
- 10 core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::getInitialState()
Overrides WorkflowTypeBase::getInitialState
File
-
core/
modules/ content_moderation/ src/ Plugin/ WorkflowType/ ContentModeration.php, line 304
Class
- ContentModeration
- Attaches workflows to content entity types and their bundles.
Namespace
Drupal\content_moderation\Plugin\WorkflowTypeCode
public function getInitialState($entity = NULL) {
// Workflows are not tied to entities, but Content Moderation adds the
// relationship between Workflows and entities. Content Moderation needs the
// entity object to be able to determine the initial state based on
// publishing status.
if (!$entity instanceof ContentEntityInterface) {
throw new \InvalidArgumentException('A content entity object must be supplied.');
}
if ($entity instanceof EntityPublishedInterface && !$entity->isNew()) {
return $this->getState($entity->isPublished() ? 'published' : 'draft');
}
return $this->getState(!empty($this->configuration['default_moderation_state']) ? $this->configuration['default_moderation_state'] : 'draft');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.