class PostApplySubscriber
Writes a file after staged changes are applied to the active directory.
This event subscriber doesn't exist in version 1.0.0 of this module, so we use it to test that new event subscribers are picked up after staged changes have been applied.
Hierarchy
- class \Drupal\updated_module\PostApplySubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of PostApplySubscriber
1 string reference to 'PostApplySubscriber'
- updated_module.services.yml in core/
modules/ package_manager/ tests/ fixtures/ build_test_projects/ updated_module/ 1.1.0/ updated_module.services.yml - core/modules/package_manager/tests/fixtures/build_test_projects/updated_module/1.1.0/updated_module.services.yml
1 service uses PostApplySubscriber
- updated_module.post_apply_subscriber in core/
modules/ package_manager/ tests/ fixtures/ build_test_projects/ updated_module/ 1.1.0/ updated_module.services.yml - Drupal\updated_module\PostApplySubscriber
File
-
core/
modules/ package_manager/ tests/ fixtures/ build_test_projects/ updated_module/ 1.1.0/ src/ PostApplySubscriber.php, line 18
Namespace
Drupal\updated_moduleView source
class PostApplySubscriber implements EventSubscriberInterface {
/**
* The path locator service.
*
* @var \Drupal\package_manager\PathLocator
*/
private $pathLocator;
/**
* Constructs a PostApplySubscriber.
*
* @param \Drupal\package_manager\PathLocator $path_locator
* The path locator service.
*/
public function __construct(PathLocator $path_locator) {
$this->pathLocator = $path_locator;
}
/**
* Writes a file when staged changes are applied to the active directory.
*/
public function postApply() : void {
$dir = $this->pathLocator
->getProjectRoot();
file_put_contents("{$dir}/bravo.txt", 'Bravo!');
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
return [
PostApplyEvent::class => 'postApply',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
PostApplySubscriber::$pathLocator | private | property | The path locator service. |
PostApplySubscriber::getSubscribedEvents | public static | function | |
PostApplySubscriber::postApply | public | function | Writes a file when staged changes are applied to the active directory. |
PostApplySubscriber::__construct | public | function | Constructs a PostApplySubscriber. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.