Skip to content

Commit ad97928

Browse files
patrykwozinskiprgTW
authored andcommitted
Support for Symfony 4.x (#4)
* Support for Symfony 4.x * Updated code
1 parent c130221 commit ad97928

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

AssetsBundle/DependencyInjection/DocplannerAssetsExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Docplanner\AssetsBundle\DependencyInjection;
44

5+
use RuntimeException;
6+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
57
use Symfony\Component\DependencyInjection\ContainerBuilder;
68
use Symfony\Component\Config\FileLocator;
79
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -40,7 +42,7 @@ public function load(array $configs, ContainerBuilder $container)
4042

4143
if (false === file_exists($path))
4244
{
43-
throw new \RuntimeException(sprintf('File "%s" not found(asset "%s")!', $path, $assetName));
45+
throw new RuntimeException(sprintf('File "%s" not found(asset "%s")!', $path, $assetName));
4446
}
4547

4648
if ($config['use_revisions'])
@@ -78,7 +80,7 @@ public function load(array $configs, ContainerBuilder $container)
7880

7981
$container->setParameter('docplanner_assets.config', $config);
8082

81-
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
83+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
8284
$loader->load('services.yml');
8385
}
8486

@@ -93,14 +95,14 @@ protected function loadManifestAssets($manifestFile)
9395

9496
if(!is_array($manifest))
9597
{
96-
throw new \RuntimeException(sprintf('Cannot parse manifest file `%s`', $manifestFile));
98+
throw new RuntimeException(sprintf('Cannot parse manifest file `%s`', $manifestFile));
9799
}
98100

99101
self::$parsedManifests[$manifestFile] = $manifest;
100102
}
101103
else
102104
{
103-
throw new \RuntimeException(sprintf('Manifest file `%s` not found', $manifestFile));
105+
throw new RuntimeException(sprintf('Manifest file `%s` not found', $manifestFile));
104106
}
105107
}
106108

AssetsBundle/Service/AssetsPicker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Docplanner\AssetsBundle\Service;
88

9+
use LogicException;
910
use Docplanner\AssetsBundle\IO\Asset;
1011
use Symfony\Component\HttpFoundation\RequestStack;
1112

@@ -40,7 +41,7 @@ public function __construct(RequestStack $requestStack, array $config)
4041
public function pickAssets($type, $forceRoute = null)
4142
{
4243
if (false === array_key_exists($type, $this->config['types'])) {
43-
throw new \LogicException(sprintf('Type "%s" is not defined!', $type));
44+
throw new LogicException(sprintf('Type "%s" is not defined!', $type));
4445
}
4546

4647
$route = $forceRoute ? $forceRoute : ($this->requestStack->getMasterRequest() ? $this->requestStack->getMasterRequest()->get('_route') : null);

AssetsBundle/Service/AssetsRepository.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Docplanner\AssetsBundle\Service;
88

9+
use LogicException;
910
use Docplanner\AssetsBundle\IO\Asset;
1011

1112
class AssetsRepository
@@ -38,7 +39,7 @@ public function getAssetsList($type)
3839

3940
if (false === array_key_exists($type, $this->config['types']))
4041
{
41-
throw new \LogicException(sprintf('Type "%s" is not defined!', $type));
42+
throw new LogicException(sprintf('Type "%s" is not defined!', $type));
4243
}
4344

4445
$this->data[$type] = [];
@@ -62,7 +63,7 @@ public function getAsset($type, $assetName)
6263

6364
if (false === array_key_exists($assetName, $assets))
6465
{
65-
throw new \LogicException(sprintf('Asset "%s" not defined in type "%s"!', $assetName, $type));
66+
throw new LogicException(sprintf('Asset "%s" not defined in type "%s"!', $assetName, $type));
6667
}
6768

6869
return $assets[$assetName];

AssetsBundle/Twig/AssetsExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Docplanner\AssetsBundle\Twig;
44

5+
use Twig_Extension;
6+
use Twig_SimpleFunction;
57
use Docplanner\AssetsBundle\Service\AssetsLoader;
68

7-
class AssetsExtension extends \Twig_Extension
9+
class AssetsExtension extends Twig_Extension
810
{
911
/** @var AssetsLoader $assetsLoader */
1012
private $assetsLoader;
@@ -23,7 +25,7 @@ public function __construct(AssetsLoader $assetsLoader)
2325
public function getFunctions()
2426
{
2527
return [
26-
new \Twig_SimpleFunction('assets_*', [$this->assetsLoader, 'assets'], ['is_safe' => ['html']]),
28+
new Twig_SimpleFunction('assets_*', [$this->assetsLoader, 'assets'], ['is_safe' => ['html']]),
2729
];
2830
}
2931

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"require": {
1616
"php": ">=7.1",
17-
"symfony/framework-bundle": "~2.3|~3.0",
17+
"symfony/framework-bundle": "~2.3|~3.0|~4.0",
1818
"twig/twig": "1.*"
1919
},
2020
"autoload": {

0 commit comments

Comments
 (0)