PHP code example of maba / dependency-injection-extra
1. Go to this page and download the library: Download maba/dependency-injection-extra library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maba / dependency-injection-extra example snippets
class SomeBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new AddTaggedCompilerPass(
'some_bundle.registry',
'my_provider',
'addProvider',
array( // this parameter is optional and defines attributes to pass from tag
'name', //
class Registry
{
// first - tagged service. Others (optional) in the order as they come in the attributes array
public function addProvider(ProviderInterface $provider, $name, $theme)
{
$this->providers[$name] = $provider; // or whatever
}
}
$registry->addProvider($niceProvider, 'nice', 'not a default one'); // priority -1 - smallest
$registry->addProvider($anotherProvider, 'another', 'default'); // priority defaults to 0
$registry->addProvider($awesomeProvider, 'awesome', 'default'); // priority is over 9000
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.