You are here

protected function AvatarKitDownloadUtility::logViolations in Avatar Kit 8.2

Validates a file entity and logs any violations.

Parameters

\Drupal\file\FileInterface $entity: A file entity to validate.

Return value

int Number of violations logged.

File

src/AvatarKitDownloadUtility.php, line 189

Class

AvatarKitDownloadUtility
Utility for creating Drupal files from responses.

Namespace

Drupal\avatars

Code

protected function logViolations(FileInterface $entity) : int {
  $violations = $entity
    ->validate();
  if ($violations) {
    foreach ($violations as $violation) {
      $message = $violation
        ->getMessage();
      $this->logger
        ->notice('Unable to save file %file: %message.', [
        '%file' => $entity
          ->getFileUri(),
        '%message' => $message,
      ]);
    }
  }
  return $violations
    ->count();
}