You are here

public static function WebformCompositeBase::isSupportedElementType in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::isSupportedElementType()

Determine if element type is supported by custom composite elements.

Parameters

string $type: An element type.

Return value

bool TRUE if element type is supported by custom composite elements.

2 calls to WebformCompositeBase::isSupportedElementType()
WebformElementComposite::processWebformElementComposite in src/Element/WebformElementComposite.php
Processes a webform element composite (builder) element.
WebformElementHelper::getIgnoredProperties in src/Utility/WebformElementHelper.php
Get ignored properties from a webform element.

File

src/Plugin/WebformElement/WebformCompositeBase.php, line 1480

Class

WebformCompositeBase
Provides a base for composite elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public static function isSupportedElementType($type) {

  /** @var \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager */
  $element_manager = \Drupal::service('plugin.manager.webform.element');

  // Skip element types that are not supported.
  $element = [
    '#type' => $type,
  ];
  $element_plugin = $element_manager
    ->getElementInstance($element);
  if (!$element_plugin
    ->isInput($element) || $element_plugin
    ->isComposite() || $element_plugin
    ->isContainer($element) || $element_plugin
    ->hasMultipleValues($element) || $element_plugin instanceof WebformElementEntityReferenceInterface && !$element_plugin instanceof WebformManagedFileBase || $element_plugin instanceof WebformElementComputedInterface) {
    return FALSE;
  }

  // Skip ignored types that are not supported.
  $ignored_element_types = [
    'hidden',
    'value',
    'webform_element',
    'webform_autocomplete',
    'webform_image_select',
    'webform_terms_of_service',
  ];
  if (in_array($type, $ignored_element_types)) {
    return FALSE;
  }
  return TRUE;
}