-
-
Save itsekhmistro/d94c86e9ee42eb221f46539c6371c781 to your computer and use it in GitHub Desktop.
Swap out service for a decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Contains Drupal\my_module\MyModuleServiceProvider | |
*/ | |
namespace Drupal\my_module; | |
use Drupal\Core\DependencyInjection\ContainerBuilder; | |
use Drupal\Core\DependencyInjection\ServiceProviderBase; | |
/** | |
* Modifies the language manager service. | |
*/ | |
class MyModuleServiceProvider extends ServiceProviderBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function alter(ContainerBuilder $container) { | |
// Overrides entity.manager service for our own. | |
$currentService = $container->get('entity.manager'); | |
$container->set('entity.manager', new MyEntityManagerDecorator($currentService)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment