You are here

class FilesystemValidator in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 src/Service/Filesystem/FilesystemValidator.php \Drupal\simple_oauth\Service\Filesystem\FilesystemValidator
  2. 8.3 src/Service/Filesystem/FilesystemValidator.php \Drupal\simple_oauth\Service\Filesystem\FilesystemValidator

@internal

Hierarchy

Expanded class hierarchy of FilesystemValidator

1 file declares its use of FilesystemValidator
KeyGeneratorService.php in src/Service/KeyGeneratorService.php

File

src/Service/Filesystem/FilesystemValidator.php, line 11

Namespace

Drupal\simple_oauth\Service\Filesystem
View source
class FilesystemValidator {

  /**
   * @var \Drupal\simple_oauth\Service\Filesystem\FileSystemChecker
   */
  private $fileSystemChecker;

  /**
   * FilesystemValidator constructor.
   *
   * @param \Drupal\simple_oauth\Service\Filesystem\FileSystemChecker $file_system_checker
   */
  public function __construct(FileSystemChecker $file_system_checker) {
    $this->fileSystemChecker = $file_system_checker;
  }

  /**
   * Validate {@var $ext_name} extension exist.
   *
   * @param string $ext_name
   *   extension name.
   *
   * @throws \Drupal\simple_oauth\Service\Exception\ExtensionNotLoadedException
   */
  public function validateOpensslExtensionExist($ext_name) {
    if (!$this->fileSystemChecker
      ->isExtensionEnabled($ext_name)) {
      throw new ExtensionNotLoadedException(strtr('Extension "@ext" is not enabled.', [
        '@ext' => $ext_name,
      ]));
    }
  }

  /**
   * Validate that {@var $paths} are directories.
   *
   * @param array $paths
   *   List of URIs.
   *
   * @throws \Drupal\simple_oauth\Service\Exception\FilesystemValidationException
   */
  public function validateAreDirs($paths) {
    foreach ($paths as $path) {
      if (!$this->fileSystemChecker
        ->isDirectory($path)) {
        throw new FilesystemValidationException(strtr('Directory "@path" is not a valid directory.', [
          '@path' => $path,
        ]));
      }
    }
  }

  /**
   * Validate that {@var $paths} are writable.
   *
   * @param array $paths
   *   List of URIs.
   *
   * @throws \Drupal\simple_oauth\Service\Exception\FilesystemValidationException
   */
  public function validateAreWritable($paths) {
    foreach ($paths as $path) {
      if (!$this->fileSystemChecker
        ->isWritable($path)) {
        throw new FilesystemValidationException(strtr('Path "@path" is not writable.', [
          '@path' => $path,
        ]));
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FilesystemValidator::$fileSystemChecker private property
FilesystemValidator::validateAreDirs public function Validate that {
FilesystemValidator::validateAreWritable public function Validate that {
FilesystemValidator::validateOpensslExtensionExist public function Validate {
FilesystemValidator::__construct public function FilesystemValidator constructor.