Created
March 31, 2016 10:46
-
-
Save e0ipso/d6e4052432abf503e60d629536eb51af to your computer and use it in GitHub Desktop.
Swap out service for a decorator
This file contains hidden or 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