You are here

class PhpSapi in Automatic Updates 8

Warn if PHP SAPI changes between checker executions.

Hierarchy

Expanded class hierarchy of PhpSapi

1 string reference to 'PhpSapi'
automatic_updates.services.yml in ./automatic_updates.services.yml
automatic_updates.services.yml
1 service uses PhpSapi
automatic_updates.php_sapi in ./automatic_updates.services.yml
Drupal\automatic_updates\ReadinessChecker\PhpSapi

File

src/ReadinessChecker/PhpSapi.php, line 11

Namespace

Drupal\automatic_updates\ReadinessChecker
View source
class PhpSapi implements ReadinessCheckerInterface {
  use StringTranslationTrait;

  /**
   * The state service.
   *
   * @var \Drupal\Core\State\StateInterface
   */
  protected $state;

  /**
   * PhpSapi constructor.
   *
   * @param \Drupal\Core\State\StateInterface $state
   *   The state service.
   */
  public function __construct(StateInterface $state) {
    $this->state = $state;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {
    $messages = [];
    $php_sapi = $this->state
      ->get('automatic_updates.php_sapi', PHP_SAPI);
    if ($php_sapi !== PHP_SAPI) {
      $messages[] = $this
        ->t('PHP changed from running as "@previous" to "@current". This can lead to inconsistent and misleading results.', [
        '@previous' => $php_sapi,
        '@current' => PHP_SAPI,
      ]);
    }
    $this->state
      ->set('automatic_updates.php_sapi', PHP_SAPI);
    return $messages;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpSapi::$state protected property The state service.
PhpSapi::run public function Run check. Overrides ReadinessCheckerInterface::run
PhpSapi::__construct public function PhpSapi constructor.
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.