/** * @param ComponentInterface $source * @param FormState $state * @param string $validator * @param ...$params * @return bool */ public function evaluate(ComponentInterface $source, FormState $state, $validator = Validator::HAS_VALUE, ...$params) { //print_rf($source->getValue()); // if it is not a data unit component, always return false if (!$source instanceof DataUnitComponentInterface) { return false; } // try to get the validator from the services $validator = $state->getServices()->getValidators()->get($validator); //print_rf($source->describe()); //exit; // return if the validator validates return $validator->validate($source->getValue(), $params); }
/** * @param ComponentInterface $component */ public function registerComponent(ComponentInterface $component) { $this->componentsById[$component->getFullId()] = $component; // register value if it is a data unit if ($component instanceof DataUnitComponentInterface) { if (!$component->shouldIgnoreValue()) { $this->values[$component->getFullName()] = $component->getValue(); } $this->componentsByName[$component->getFullName()] = $component; } }