/** * Validates the model object, rejecting the fields that fail validation * * @param ModelObject $model The object to validate * * @return void */ public function validateModelObject(ModelObject $model) { $fields = $model->getPersistentFields(); foreach ($fields as $fieldName) { $value = $model->{$fieldName}; $fieldResolved = get_class($model) . '.' . $fieldName; $this->rejectIfInvalid($fieldResolved, 'field', $model->getFieldTitle($fieldName), $value, new ValidationExpression($model->getValidation($fieldName))); } }
/** * Returns an array of only the persistent fields of {@link $model} * * @param ModelObject $model The modelObject to analyze * * @return array An array with persistent field names as keys with their values */ public function modelToPersistentArray(ModelObject $model) { $persistent = array_intersect_key($model->toArray(), array_flip($model->getPersistentFields())); return $persistent; }