tomcizek / symfony-interop-container
Symfony Interop Container,其 'config' 键下有配置数组 - 用于使用互操作性工厂的扩展。
1.1.0
2017-10-10 12:50 UTC
Requires
- php: ^7.1
- psr/container: ^1.0
- sandrokeil/interop-config: ^2.1
- symfony/config: ^3.3
- symfony/dependency-injection: ^3.3
- symfony/expression-language: ^3.3
- symfony/framework-bundle: ^3.3
- symfony/http-kernel: ^3.3
- symfony/yaml: ^3.3
Requires (Dev)
- phpstan/phpstan: ^0.8.5
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2024-10-01 19:05:32 UTC
README
当您想要创建一个使用互操作性配置(interop config)的 symfony 厂商扩展包时,这个捆绑包非常方便。
为什么这么做呢?
它会为您注册 'interop_container' 服务,这个服务与默认的 'service_container' 具有相同的服务,并且它返回键为 'config' 的应用配置数组。这个配置是您需要在您的扩展中定义的。
快速开始
1) 通过 composer 安装此库
composer require tomcizek/symfony-interop-container
2) 在您的 kernel 中注册 SymfonyInteropContainerBundle
3) 创建您的 Bundle,包括扩展并在 kernel 中注册,例如
class TestExtension extends AbstractInteropExtension { public function load(array $configs, ContainerBuilder $containerBuilder) { // parent call is mandatory, or it will not work as expected! parent::load($configs, $containerBuilder); // we can set another config key (default is extension alias: $this->getAlias()) $this->configBuilder->setKey('test'); // we can merge over another config $this->configBuilder->mergeOverByConfig([]); // we can merge over multiple configs $this->configBuilder->mergeOverByConfigs([[]]); // we can merge default config $this->configBuilder->mergeDefaultConfig([]); // if you want, you can build config by: $config = $this->configBuilder->build(); // it will be built in process method and injected into interop_container service } public function process(ContainerBuilder $containerBuilder) { // If you need to redefine process method, parent call is mandatory. parent::process($containerBuilder); } }
贡献
请随意分叉并扩展现有功能或添加新功能,并将您的更改通过 pull request 发送!为了保持一致的代码质量,请为您的所有更改提供单元测试,并可能更新文档。