You are here

private function AllowedValuesConstraintValidator::getMainPropertyValue in Select (or other) 8

Same name and namespace in other branches
  1. 4.x src/Plugin/Validation/AllowedValuesConstraintValidator.php \Drupal\select_or_other\Plugin\Validation\AllowedValuesConstraintValidator::getMainPropertyValue()
1 call to AllowedValuesConstraintValidator::getMainPropertyValue()
AllowedValuesConstraintValidator::validate in src/Plugin/Validation/AllowedValuesConstraintValidator.php
Checks if the passed value is valid.

File

src/Plugin/Validation/AllowedValuesConstraintValidator.php, line 100

Class

AllowedValuesConstraintValidator
Validates the AllowedValues constraint.

Namespace

Drupal\select_or_other\Plugin\Validation

Code

private function getMainPropertyValue($typed_data) {
  $name = $typed_data
    ->getDataDefinition()
    ->getMainPropertyName();
  if (!isset($name)) {
    throw new \LogicException('Cannot validate allowed values for complex data without a main property.');
  }
  return $typed_data
    ->get($name)
    ->getValue();
}