protected function validate(FileInterface
$file, array
$validators) { $violations =
$file->
validate();
// Remove violations of inaccessible fields as they cannot stem from our
// changes.
$violations->
filterByFieldAccess();
// Validate the file based on the field definition configuration.
$errors =
file_validate($file,
$validators);
if (!
empty($errors)) { $translator =
new DrupalTranslator();
foreach ($errors as $error) { $violation =
new ConstraintViolation($translator->
trans($error),
(string) $error,
[],
EntityAdapter::
createFromEntity($file),
'',
NULL
);
$violations->
add($violation);
} }