Skip to content

Commit 241f66e

Browse files
committed
Compability with Symfony 4.x
1 parent dcf699f commit 241f66e

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
}
1515
],
1616
"autoload": {
17-
"psr-4": {"ProklUng\\ContainerBoilerplate\\": "src" }
17+
"psr-4": {"ProklUng\\ContainerBoilerplate\\": "src" },
18+
"files": ["functions/helpers.php"]
1819
},
1920
"autoload-dev": {
2021
"psr-4": {"ProklUng\\ContainerBoilerplate\\Tests\\": "tests" }

functions/helpers.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
// Compability with Symfony 4.x
4+
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
5+
use Symfony\Component\DependencyInjection\Definition;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\EnvConfigurator;
7+
use Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator;
8+
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;
9+
10+
if (!function_exists('service')) {
11+
/**
12+
* Creates a reference to a service.
13+
*
14+
* @param string $serviceId Service ID.
15+
*
16+
* @return ReferenceConfigurator
17+
*/
18+
function service(string $serviceId): ReferenceConfigurator
19+
{
20+
return new ReferenceConfigurator($serviceId);
21+
}
22+
}
23+
24+
if (!function_exists('inline_service')) {
25+
/**
26+
* Creates an inline service.
27+
*/
28+
function inline_service(string $class = null): InlineServiceConfigurator
29+
{
30+
return new InlineServiceConfigurator(new Definition($class));
31+
}
32+
}
33+
34+
if (!function_exists('abstract_arg')) {
35+
/**
36+
* Creates an abstract argument.
37+
*/
38+
function abstract_arg(string $description): AbstractArgument
39+
{
40+
return new AbstractArgument($description);
41+
}
42+
}
43+
44+
if (!function_exists('env')) {
45+
/**
46+
* Creates an environment variable reference.
47+
*/
48+
function env(string $name): EnvConfigurator
49+
{
50+
return new EnvConfigurator($name);
51+
}
52+
}

0 commit comments

Comments
 (0)