public function WorkflowState::showWidget in Workflow 8
Determines if the Workflow Form must be shown.
If not, a formatter must be shown, since there are no valid options.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
string $field_name:
\Drupal\Core\Session\AccountInterface $account:
bool $force:
Return value
bool TRUE = a form (a.k.a. widget) must be shown; FALSE = no form, a formatter must be shown instead.
File
- src/
Entity/ WorkflowState.php, line 357
Class
- WorkflowState
- Workflow configuration entity to persistently store configuration.
Namespace
Drupal\workflow\EntityCode
public function showWidget(EntityInterface $entity, $field_name, AccountInterface $account, $force) {
$options = $this
->getOptions($entity, $field_name, $account, $force);
$count = count($options);
// The easiest case first: more then one option: always show form.
if ($count > 1) {
return TRUE;
}
// #2226451: Even in Creation state, we must have 2 visible states to show the widget.
// // Only when in creation phase, one option is sufficient,
// // since the '(creation)' option is not included in $options.
// // When in creation state,
// if ($this->isCreationState()) {
// return TRUE;
// }
return FALSE;
}