class RsyncValidator
Checks that rsync is available.
@internal This is an internal part of Package Manager and may be changed or removed at any time without warning. External code should not interact with this class.
Hierarchy
- class \Drupal\package_manager\Validator\RsyncValidator implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of RsyncValidator
1 file declares its use of RsyncValidator
- RsyncValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ RsyncValidatorTest.php
File
-
core/
modules/ package_manager/ src/ Validator/ RsyncValidator.php, line 25
Namespace
Drupal\package_manager\ValidatorView source
final class RsyncValidator implements EventSubscriberInterface {
use StringTranslationTrait;
public function __construct(ExecutableFinderInterface $executableFinder, ModuleHandlerInterface $moduleHandler) {
}
/**
* Checks that rsync is available.
*
* @param \Drupal\package_manager\Event\PreOperationStageEvent $event
* The event being handled.
*/
public function validate(PreOperationStageEvent $event) : void {
try {
$this->executableFinder
->find('rsync');
$rsync_found = TRUE;
} catch (LogicException) {
$rsync_found = FALSE;
}
if ($rsync_found === FALSE) {
$message = $this->t('<code>rsync</code> is not available.');
if ($this->moduleHandler
->moduleExists('help')) {
$help_url = Url::fromRoute('help.page')->setRouteParameter('name', 'package_manager')
->setOption('fragment', 'package-manager-faq-rsync')
->toString();
$message = $this->t('@message See the <a href=":url">Package Manager help</a> for more information on how to resolve this.', [
'@message' => $message,
':url' => $help_url,
]);
}
$event->addError([
$message,
]);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
return [
StatusCheckEvent::class => 'validate',
PreCreateEvent::class => 'validate',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
RsyncValidator::getSubscribedEvents | public static | function | ||
RsyncValidator::validate | public | function | Checks that rsync is available. | |
RsyncValidator::__construct | public | function | ||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 |
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. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.