If your module depends on the service of another module , we do not have a very good way to get injection currently. You can't just add it as an argument. You would need to write something ContainerAware and that's ouch. Here's a patch.
Here's how it works:
arguments: ['@plugin.manager.entity']
tags:
- {name: optional_dependency, block_manager: '@plugin.manager.block' }
And then
<?php
function __construct(EntityManager $entity_manager, array $optional_dependencies = array()) {
$this->entityManager = $entity_manager;
if (isset($optional_dependencies['block_manager'])) {
$this->blockManager = $optional_dependencies['block_manager'];
}
}
function postSave() {
if ($this->blockManager) {
$this->blockManager->clearCachedDefinitions();
}
}
?>
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
OptionalDependencyPass.patch | 2.9 KB | Idle | FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion. | View details | Re-test |