protected function WebformNodeReferencesListController::getWebformStatus in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_node/src/Controller/WebformNodeReferencesListController.php \Drupal\webform_node\Controller\WebformNodeReferencesListController::getWebformStatus()
Get the webform node's status.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The node.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup|null The webform node status.
See also
\Drupal\webform\Plugin\Field\FieldFormatter\WebformEntityReferenceFormatterBase::isOpen
1 call to WebformNodeReferencesListController::getWebformStatus()
- WebformNodeReferencesListController::buildRow in modules/
webform_node/ src/ Controller/ WebformNodeReferencesListController.php - Builds a row for an entity in the entity listing.
File
- modules/
webform_node/ src/ Controller/ WebformNodeReferencesListController.php, line 246
Class
- WebformNodeReferencesListController
- Defines a controller for webform node references.
Namespace
Drupal\webform_node\ControllerCode
protected function getWebformStatus(EntityInterface $entity) {
// Get source entity's webform field.
$webform_field_name = $this->webformEntityReferenceManager
->getFieldName($entity);
if (!$webform_field_name) {
return NULL;
}
if ($entity->{$webform_field_name}->target_id !== $this->webform
->id()) {
return NULL;
}
$webform_field = $entity->{$webform_field_name};
if ($webform_field->status === WebformInterface::STATUS_OPEN) {
return $this
->t('Open');
}
if ($webform_field->status === WebformInterface::STATUS_SCHEDULED) {
$is_opened = TRUE;
if ($webform_field->open && strtotime($webform_field->open) > time()) {
$is_opened = FALSE;
}
$is_closed = FALSE;
if ($webform_field->close && strtotime($webform_field->close) < time()) {
$is_closed = TRUE;
}
return $is_opened && !$is_closed ? $this
->t('Open') : $this
->t('Closed');
}
return $this
->t('Closed');
}