protected function WebformSubmissionViewBuilder::isElementVisible in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformSubmissionViewBuilder.php \Drupal\webform\WebformSubmissionViewBuilder::isElementVisible()
Determines if an element is visible.
Parameters
array $element: The element to check for visibility.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options:
- excluded_elements: An array of elements to be excluded.
- ignore_access: Flag to ignore private and/or access controls and always display the element.
- email: Format element to be send via email.
Return value
bool TRUE if the element is visible, otherwise FALSE.
See also
\Drupal\webform\WebformSubmissionConditionsValidatorInterface::isElementVisible
\Drupal\Core\Render\Element::isVisibleElement
2 calls to WebformSubmissionViewBuilder::isElementVisible()
- WebformSubmissionViewBuilder::buildElements in src/
WebformSubmissionViewBuilder.php - Build element display items from elements and submitted data.
- WebformSubmissionViewBuilder::buildTable in src/
WebformSubmissionViewBuilder.php - Build table display from elements and submitted data.
File
- src/
WebformSubmissionViewBuilder.php, line 266
Class
- WebformSubmissionViewBuilder
- Render controller for webform submissions.
Namespace
Drupal\webformCode
protected function isElementVisible(array $element, WebformSubmissionInterface $webform_submission, array $options) {
// Checked excluded elements.
if (isset($element['#webform_key']) && isset($options['excluded_elements'][$element['#webform_key']])) {
return FALSE;
}
// Checked excluded attachments, except from composite elements.
// @see \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::formatComposite
if (!empty($options['exclude_attachments'])) {
/** @var \Drupal\webform\Plugin\WebformElementInterface $webform_element */
$webform_element = $this->elementManager
->getElementInstance($element, $webform_submission);
if ($webform_element instanceof WebformElementAttachmentInterface && !$webform_element instanceof WebformElementCompositeInterface) {
return FALSE;
}
}
// Check if the element is conditionally hidden.
if (!$this->conditionsValidator
->isElementVisible($element, $webform_submission)) {
return FALSE;
}
// Check if ignore access is set.
// This is used email handlers to include administrative elements in emails.
if (!empty($options['ignore_access'])) {
return TRUE;
}
// Check check the element's #access.
if (isset($element['#access']) && ($element['#access'] instanceof AccessResultInterface && $element['#access']
->isForbidden() || $element['#access'] === FALSE)) {
return FALSE;
}
// Finally, check the element's 'view' access.
/** @var \Drupal\webform\Plugin\WebformElementInterface $webform_element */
$webform_element = $this->elementManager
->getElementInstance($element, $webform_submission);
return $webform_element
->checkAccessRules('view', $element) ? TRUE : FALSE;
}