[ 'value' => [ 'type' => 'char', 'length' => 2, 'not null' => FALSE, ], ], 'indexes' => [ 'value' => ['value'], ], ]; } /** * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') ->setLabel(t('Country')); return $properties; } /** * {@inheritdoc} */ public static function defaultFieldSettings() { return self::defaultCountrySettings(); } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { return $this->countrySettingsForm($form, $form_state); } /** * {@inheritdoc} */ public function isEmpty() { return empty($this->value); } /** * {@inheritdoc} */ public function getConstraints() { $constraints = parent::getConstraints(); $constraint_manager = $this->getTypedDataManager()->getValidationConstraintManager(); $constraints[] = $constraint_manager->create('ComplexData', [ 'value' => [ 'Country' => [ 'availableCountries' => $this->getAvailableCountries(), ], ], ]); return $constraints; } }