Skip to content

Commit

Permalink
Compability with Symfony 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ProklUng committed Aug 10, 2021
1 parent dcf699f commit 241f66e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
}
],
"autoload": {
"psr-4": {"ProklUng\\ContainerBoilerplate\\": "src" }
"psr-4": {"ProklUng\\ContainerBoilerplate\\": "src" },
"files": ["functions/helpers.php"]
},
"autoload-dev": {
"psr-4": {"ProklUng\\ContainerBoilerplate\\Tests\\": "tests" }
Expand Down
52 changes: 52 additions & 0 deletions functions/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

// Compability with Symfony 4.x
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\Configurator\EnvConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

if (!function_exists('service')) {
/**
* Creates a reference to a service.
*
* @param string $serviceId Service ID.
*
* @return ReferenceConfigurator
*/
function service(string $serviceId): ReferenceConfigurator
{
return new ReferenceConfigurator($serviceId);
}
}

if (!function_exists('inline_service')) {
/**
* Creates an inline service.
*/
function inline_service(string $class = null): InlineServiceConfigurator
{
return new InlineServiceConfigurator(new Definition($class));
}
}

if (!function_exists('abstract_arg')) {
/**
* Creates an abstract argument.
*/
function abstract_arg(string $description): AbstractArgument
{
return new AbstractArgument($description);
}
}

if (!function_exists('env')) {
/**
* Creates an environment variable reference.
*/
function env(string $name): EnvConfigurator
{
return new EnvConfigurator($name);
}
}

0 comments on commit 241f66e

Please sign in to comment.