Skip to content

Commit 1111881

Browse files
committed
fix
1 parent 34c68a4 commit 1111881

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

‎pkg/enqueue/Symfony/DefaultTransportFactory.php‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Enqueue\Null\Symfony\NullTransportFactory;
1313
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
15-
use Symfony\Component\HttpKernel\Kernel;
1615
use function Enqueue\dsn_to_connection_factory;
1716

1817
class DefaultTransportFactory implements TransportFactoryInterface
@@ -144,20 +143,17 @@ public function getName()
144143
*/
145144
private function resolveDSN(ContainerBuilder $container, $dsn)
146145
{
147-
// Symfony 2.x does not such env syntax
148-
if (version_compare(Kernel::VERSION, '3.0', '<')) {
149-
return $dsn;
150-
}
146+
if (method_exists($container, 'resolveEnvPlaceholders')) {
147+
$dsn = $container->resolveEnvPlaceholders($dsn);
151148

152-
$dsn = $container->resolveEnvPlaceholders($dsn);
149+
$matches = [];
150+
if (preg_match('/%env\((.*?)\)/', $dsn, $matches)) {
151+
if (false === $realDsn = getenv($matches[1])) {
152+
throw new \LogicException(sprintf('The env "%s" var is not defined', $matches[1]));
153+
}
153154

154-
$matches = [];
155-
if (preg_match('/%env\((.*?)\)/', $dsn, $matches)) {
156-
if (false === $realDsn = getenv($matches[1])) {
157-
throw new \LogicException(sprintf('The env "%s" var is not defined', $matches[1]));
155+
return $realDsn;
158156
}
159-
160-
return $realDsn;
161157
}
162158

163159
return $dsn;

0 commit comments

Comments
 (0)