https://github.com/thecodingmachine/drupal-service-provider-bridge
This Drupal 8 module provides a bridge to include container-interop/service-provider service providers into your Drupal project.
https://github.com/thecodingmachine/drupal-service-provider-bridge
Last synced: 3 months ago
JSON representation
This Drupal 8 module provides a bridge to include container-interop/service-provider service providers into your Drupal project.
- Host: GitHub
- URL: https://github.com/thecodingmachine/drupal-service-provider-bridge
- Owner: thecodingmachine
- Created: 2016-12-06T17:33:07.000Z (over 9 years ago)
- Default Branch: 0.3
- Last Pushed: 2016-12-15T21:43:19.000Z (over 9 years ago)
- Last Synced: 2025-02-16T12:30:26.493Z (over 1 year ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# container-interop/service-provider Drupal 8 module
Import `service-provider` as defined in `container-interop` into a Drupal 8 project.
## Usage
### Installation
Install the package using Composer:
```js
composer require thecodingmachine/drupal-service-provider-bridge
```
Go to Drupal administration panel, to the "Extensions" page and enable the "Service providers integration" module.
### Puli fix
There is currently an issue with Puli loading.
To fix it, create a `load_puli.php` file at the root of your project:
**load_puli.php**
```php
[
'My\\Project\\Di\\MyServiceProvider',
'My\\Project\\Di\\MyOtherServiceProvider',
]
];
```
## Disabling Puli discovery
You can disable Puli discovery by passing `'puli' => false` in the `service-providers.php` file:
**service-providers.php**
```php
return [
'service-providers' => [
'My\\Project\\Di\\MyServiceProvider',
'My\\Project\\Di\\MyOtherServiceProvider',
],
'puli' => false
];
```
Note: instead of returning a fully-qualified class name, you can also put in the array an instance of a service provider directly.
## Known limitations
Drupal 8 container only accepts **lower-case identifiers**.
Since service providers can provide any kind of identifiers for services (both upper and lower case), this bridge systematically put cast the identifiers in lower-case.
This can introduce bugs if you have 2 services that have the same name in different cases (but honnestly, you should reconsider the way you design your service providers if you have this issue :) )
## Default aliases
By default, this package provides will create the following entries:
- `Psr\Log\LoggerInterface` => alias to `logger.channel.default`
- `puli_factory` => The Puli factory
- `puli_repository` => The Puli repository
- `puli_discovery` => The Puli discovery service
## How it works
Behind the scene, this Drupal 8 module heavily relies on the [Symfony <=> service-provider bridge bundle](https://github.com/thecodingmachine/service-provider-bridge-bundle).
Indeed, Drupal 8 container is a heavily adapted container based on Symfony container. This module is therefore a set of adaptations from the Symfony bridge.