class DiskSpace in Automatic Updates 8
Disk space checker.
Hierarchy
- class \Drupal\automatic_updates\ReadinessChecker\Filesystem implements ReadinessCheckerInterface uses StringTranslationTrait
- class \Drupal\automatic_updates\ReadinessChecker\DiskSpace
Expanded class hierarchy of DiskSpace
1 file declares its use of DiskSpace
- DiskSpaceTest.php in tests/
src/ Kernel/ ReadinessChecker/ DiskSpaceTest.php
1 string reference to 'DiskSpace'
1 service uses DiskSpace
File
- src/
ReadinessChecker/ DiskSpace.php, line 10
Namespace
Drupal\automatic_updates\ReadinessCheckerView source
class DiskSpace extends Filesystem {
/**
* Minimum disk space (in bytes) is 10mb.
*/
const MINIMUM_DISK_SPACE = 10000000;
/**
* Megabyte divisor.
*/
const MEGABYTE_DIVISOR = 1000000;
/**
* {@inheritdoc}
*/
protected function doCheck() {
return $this
->diskSpaceCheck();
}
/**
* Check if the filesystem has sufficient disk space.
*
* @return array
* An array of translatable strings if there is not sufficient space.
*/
protected function diskSpaceCheck() {
$messages = [];
if (!$this
->areSameLogicalDisk($this
->getRootPath(), $this
->getVendorPath())) {
if (disk_free_space($this
->getRootPath()) < static::MINIMUM_DISK_SPACE) {
$messages[] = $this
->t('Drupal root filesystem "@root" has insufficient space. There must be at least @space megabytes free.', [
'@root' => $this
->getRootPath(),
'@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
]);
}
if (is_dir($this
->getVendorPath()) && disk_free_space($this
->getVendorPath()) < static::MINIMUM_DISK_SPACE) {
$messages[] = $this
->t('Vendor filesystem "@vendor" has insufficient space. There must be at least @space megabytes free.', [
'@vendor' => $this
->getVendorPath(),
'@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
]);
}
}
elseif (disk_free_space($this
->getRootPath()) < static::MINIMUM_DISK_SPACE) {
$messages[] = $this
->t('Logical disk "@root" has insufficient space. There must be at least @space megabytes free.', [
'@root' => $this
->getRootPath(),
'@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
]);
}
$temp = FileSystemComponent::getOsTemporaryDirectory();
if (disk_free_space($temp) < static::MINIMUM_DISK_SPACE) {
$messages[] = $this
->t('Directory "@temp" has insufficient space. There must be at least @space megabytes free.', [
'@temp' => $temp,
'@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
]);
}
return $messages;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DiskSpace:: |
protected | function | Check if the filesystem has sufficient disk space. | |
DiskSpace:: |
protected | function |
Perform checks. Overrides Filesystem:: |
|
DiskSpace:: |
constant | Megabyte divisor. | ||
DiskSpace:: |
constant | Minimum disk space (in bytes) is 10mb. | 1 | |
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:: |
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. |