abstract class Filesystem in Automatic Updates 8
Base class for filesystem checkers.
Hierarchy
- class \Drupal\automatic_updates\ReadinessChecker\Filesystem implements ReadinessCheckerInterface uses StringTranslationTrait
Expanded class hierarchy of Filesystem
File
- src/
ReadinessChecker/ Filesystem.php, line 10
Namespace
Drupal\automatic_updates\ReadinessCheckerView source
abstract class Filesystem implements ReadinessCheckerInterface {
use StringTranslationTrait;
/**
* The root file path.
*
* @var string
*/
protected $rootPath;
/**
* The vendor file path.
*
* @var string
*/
protected $vendorPath;
/**
* Filesystem constructor.
*
* @param string $app_root
* The app root.
*/
public function __construct($app_root) {
$this->rootPath = (string) $app_root;
}
/**
* {@inheritdoc}
*/
public function run() {
if (!file_exists($this
->getRootPath() . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, [
'core',
'core.api.php',
]))) {
return [
$this
->t('The web root could not be located.'),
];
}
return $this
->doCheck();
}
/**
* Perform checks.
*
* @return array
* An array of translatable strings if any checks fail.
*/
protected abstract function doCheck();
/**
* Get the root file path.
*
* @return string
* The root file path.
*/
protected function getRootPath() {
if (!$this->rootPath) {
$this->rootPath = (string) \Drupal::root();
}
return $this->rootPath;
}
/**
* Get the vendor file path.
*
* @return string
* The vendor file path.
*/
protected function getVendorPath() {
if (!$this->vendorPath) {
$this->vendorPath = $this
->getRootPath() . DIRECTORY_SEPARATOR . 'vendor';
}
return $this->vendorPath;
}
/**
* Determine if the root and vendor file system are the same logical disk.
*
* @param string $root
* Root file path.
* @param string $vendor
* Vendor file path.
*
* @return bool
* TRUE if same file system, FALSE otherwise.
*/
protected function areSameLogicalDisk($root, $vendor) {
$root_statistics = stat($root);
$vendor_statistics = stat($vendor);
return $root_statistics && $vendor_statistics && $root_statistics['dev'] === $vendor_statistics['dev'];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Filesystem:: |
protected | property | The root file path. | |
Filesystem:: |
protected | property | The vendor file path. | |
Filesystem:: |
protected | function | Determine if the root and vendor file system are the same logical disk. | 2 |
Filesystem:: |
abstract protected | function | Perform checks. | 4 |
Filesystem:: |
protected | function | Get the root file path. | |
Filesystem:: |
protected | function | Get the vendor file path. | |
Filesystem:: |
public | function |
Run check. Overrides ReadinessCheckerInterface:: |
|
Filesystem:: |
public | function | Filesystem constructor. | 1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |