You are here

trait IgnoredPathsTrait in Automatic Updates 8

Provide a helper to check if file paths are ignored.

Hierarchy

2 files declare their use of IgnoredPathsTrait
MissingProjectInfo.php in src/ReadinessChecker/MissingProjectInfo.php
ModifiedFiles.php in src/Services/ModifiedFiles.php

File

src/IgnoredPathsTrait.php, line 8

Namespace

Drupal\automatic_updates
View source
trait IgnoredPathsTrait {

  /**
   * Check if the file path is ignored.
   *
   * @param string $file_path
   *   The file path.
   *
   * @return bool
   *   TRUE if file path is ignored, else FALSE.
   */
  protected function isIgnoredPath($file_path) {
    $paths = $this
      ->getConfigFactory()
      ->get('automatic_updates.settings')
      ->get('ignored_paths');
    if ($this
      ->getPathMatcher()
      ->matchPath($file_path, $paths)) {
      return TRUE;
    }
    return FALSE;
  }

  /**
   * Gets the config factory.
   *
   * @return \Drupal\Core\Config\ConfigFactoryInterface
   *   The config factory.
   */
  protected function getConfigFactory() {
    if (isset($this->configFactory)) {
      return $this->configFactory;
    }
    return \Drupal::configFactory();
  }

  /**
   * Get the path matcher service.
   *
   * @return \Drupal\Core\Path\PathMatcherInterface
   *   The path matcher.
   */
  protected function getPathMatcher() {
    if (isset($this->pathMatcher)) {
      return $this->pathMatcher;
    }
    return \Drupal::service('path.matcher');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
IgnoredPathsTrait::getConfigFactory protected function Gets the config factory.
IgnoredPathsTrait::getPathMatcher protected function Get the path matcher service.
IgnoredPathsTrait::isIgnoredPath protected function Check if the file path is ignored.