Skip to content

Commit 634aff4

Browse files
authored
Merge pull request #11 from symfony2admingenerator/symfony4-support
Added symfony 4 support
2 parents bc40834 + b151bab commit 634aff4

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
composer.lock
3+
composer.phar
4+
vendor

DependencyInjection/Compiler/FormCompilerPass.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\DependencyInjection\ContainerBuilder;
66
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7+
use Symfony\Component\HttpKernel\Kernel;
78

89
/**
910
* Processes twig configuration
@@ -17,23 +18,19 @@ class FormCompilerPass implements CompilerPassInterface
1718
*/
1819
public function process(ContainerBuilder $container)
1920
{
21+
// Used templates
22+
$templates = ['@AdmingeneratorForm/form_js.html.twig', '@AdmingeneratorForm/form_css.html.twig'];
23+
2024
$resources = $container->getParameter('twig.form.resources');
21-
$alreadyImported = in_array('AdmingeneratorFormBundle::form_js.html.twig', $resources)
22-
&& in_array('AdmingeneratorFormBundle::form_css.html.twig', $resources);
25+
$alreadyImported = count(array_intersect($resources, $templates)) == count($templates);
2326

2427
if (!$alreadyImported) {
2528
// Insert right after form_div_layout.html.twig if exists
2629
if (($key = array_search('form_div_layout.html.twig', $resources)) !== false) {
27-
array_splice($resources, ++$key, 0, array(
28-
'AdmingeneratorFormBundle::form_js.html.twig',
29-
'AdmingeneratorFormBundle::form_css.html.twig'
30-
));
30+
array_splice($resources, ++$key, 0, $templates);
3131
} else {
3232
// Put it in first position
33-
array_unshift($resources, array(
34-
'AdmingeneratorFormBundle::form_js.html.twig',
35-
'AdmingeneratorFormBundle::form_css.html.twig'
36-
));
33+
array_unshift($resources, $templates);
3734
}
3835

3936
$container->setParameter('twig.form.resources', $resources);

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
}
1616
],
1717
"require": {
18-
"symfony/symfony": ">= 2.2.0",
18+
"symfony/config": "~2.2|~3.0|~4.0",
19+
"symfony/dependency-injection": "~2.2|~3.0|~4.0",
20+
"symfony/form": "~2.2|~3.0|~4.0",
21+
"symfony/http-kernel": "~2.2|~3.0|~4.0",
1922
"twig/twig": "~1.26||~2.0",
2023
"twig/extensions": "~1.0"
2124
},

0 commit comments

Comments
 (0)