You are here

class MissingProjectInfo in Automatic Updates 8

Missing project info checker.

Hierarchy

Expanded class hierarchy of MissingProjectInfo

1 file declares its use of MissingProjectInfo
MissingProjectInfoTest.php in tests/src/Kernel/ReadinessChecker/MissingProjectInfoTest.php
1 string reference to 'MissingProjectInfo'
automatic_updates.services.yml in ./automatic_updates.services.yml
automatic_updates.services.yml
1 service uses MissingProjectInfo
automatic_updates.missing_project_info in ./automatic_updates.services.yml
Drupal\automatic_updates\ReadinessChecker\MissingProjectInfo

File

src/ReadinessChecker/MissingProjectInfo.php, line 13

Namespace

Drupal\automatic_updates\ReadinessChecker
View source
class MissingProjectInfo implements ReadinessCheckerInterface {
  use IgnoredPathsTrait;
  use ProjectInfoTrait;
  use StringTranslationTrait;

  /**
   * The module extension list.
   *
   * @var \Drupal\Core\Extension\ExtensionList
   */
  protected $modules;

  /**
   * The profile extension list.
   *
   * @var \Drupal\Core\Extension\ExtensionList
   */
  protected $profiles;

  /**
   * The theme extension list.
   *
   * @var \Drupal\Core\Extension\ExtensionList
   */
  protected $themes;

  /**
   * MissingProjectInfo constructor.
   *
   * @param \Drupal\Core\Extension\ExtensionList $modules
   *   The module extension list.
   * @param \Drupal\Core\Extension\ExtensionList $profiles
   *   The profile extension list.
   * @param \Drupal\Core\Extension\ExtensionList $themes
   *   The theme extension list.
   */
  public function __construct(ExtensionList $modules, ExtensionList $profiles, ExtensionList $themes) {
    $this->modules = $modules;
    $this->profiles = $profiles;
    $this->themes = $themes;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {
    return $this
      ->missingProjectInfoCheck();
  }

  /**
   * Check for projects missing project info.
   *
   * @return array
   *   An array of translatable strings if any checks fail.
   */
  protected function missingProjectInfoCheck() {
    $messages = [];
    foreach ($this
      ->getExtensionsTypes() as $extension_type) {
      foreach ($this
        ->getInfos($extension_type) as $info) {
        if ($this
          ->isIgnoredPath($info['install path'])) {
          continue;
        }
        if (!$info['version']) {
          $messages[] = $this
            ->t('The project "@extension" can not be updated because its version is either undefined or a dev release.', [
            '@extension' => $info['name'],
          ]);
        }
      }
    }
    return $messages;
  }

  /**
   * Get the extension types.
   *
   * @return array
   *   The extension types.
   */
  protected function getExtensionsTypes() {
    return [
      'modules',
      'profiles',
      'themes',
    ];
  }

}

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.
MissingProjectInfo::$modules protected property The module extension list.
MissingProjectInfo::$profiles protected property The profile extension list.
MissingProjectInfo::$themes protected property The theme extension list.
MissingProjectInfo::getExtensionsTypes protected function Get the extension types.
MissingProjectInfo::missingProjectInfoCheck protected function Check for projects missing project info.
MissingProjectInfo::run public function Run check. Overrides ReadinessCheckerInterface::run
MissingProjectInfo::__construct public function MissingProjectInfo constructor.
ProjectInfoTrait::getComposerJson protected function Get the composer.json as a JSON array.
ProjectInfoTrait::getExtensionList protected function Get extension list.
ProjectInfoTrait::getExtensionVersion protected function Get the extension version.
ProjectInfoTrait::getInfos protected function Returns an array of info files information of available extensions. 1
ProjectInfoTrait::getProjectName protected function Get the extension's project name.
ProjectInfoTrait::getSuffix protected function Get string suffix.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.