You are here

protected static function WebformElementHelper::isIgnoredProperty in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::isIgnoredProperty()

Determine if an element's property should be ignored.

  • Subelement properties are delimited using __.
  • All _validation and _callback properties are ignored.

Parameters

string $property: A property name.

Return value

bool TRUE is the property should be ignored.

See also

\Drupal\webform\Element\WebformSelectOther

\Drupal\webform\Element\WebformCompositeBase::processWebformComposite

2 calls to WebformElementHelper::isIgnoredProperty()
WebformElementHelper::getIgnoredProperties in src/Utility/WebformElementHelper.php
Get ignored properties from a webform element.
WebformElementHelper::removeIgnoredProperties in src/Utility/WebformElementHelper.php
Remove ignored properties from an element.

File

src/Utility/WebformElementHelper.php, line 480

Class

WebformElementHelper
Helper class webform element methods.

Namespace

Drupal\webform\Utility

Code

protected static function isIgnoredProperty($property) {

  // Build cached ignored sub properties regular expression.
  if (!isset(self::$ignoredSubPropertiesRegExp)) {
    $allowedSubProperties = self::$allowedProperties;
    $ignoredSubProperties = self::$ignoredProperties;

    // Allow #weight as sub property. This makes it easier for developer to
    // sort composite sub-elements.
    unset($ignoredSubProperties['#weight']);
    self::$ignoredSubPropertiesRegExp = '/__(' . implode('|', array_keys(WebformArrayHelper::removePrefix($ignoredSubProperties))) . ')$/';
    self::$allowedSubPropertiesRegExp = '/__(' . implode('|', array_keys(WebformArrayHelper::removePrefix($allowedSubProperties))) . ')$/';
  }
  if (isset(self::$allowedProperties[$property])) {
    return FALSE;
  }
  elseif (strpos($property, '__') !== FALSE && preg_match(self::$allowedSubPropertiesRegExp, $property)) {
    return FALSE;
  }
  elseif (isset(self::$ignoredProperties[$property])) {
    return TRUE;
  }
  elseif (strpos($property, '__') !== FALSE && preg_match(self::$ignoredSubPropertiesRegExp, $property)) {
    return TRUE;
  }
  elseif (preg_match('/_(validates?|callbacks?)$/', $property)) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}