8000 [HttpKernel] Reduce code complexity by merging "ClassMatcher" into "A… · symfony/symfony@43aad08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43aad08

Browse files
nicolas-grekastgalopin
authored andcommitted
[HttpKernel] Reduce code complexity by merging "ClassMatcher" into "AddClassesToCachePass"
1 parent 3504470 commit 43aad08

File tree

13 files changed

+221
-342
lines changed

13 files changed

+221
-342
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ClassCacheCacheWarmer.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\ClassLoader\ClassCollectionLoader;
1515
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
16-
use Symfony\Component\HttpKernel\CacheWarmer\ClassMatcherInterface;
1716

1817
/**
1918
* Generates the Class Cache (classes.php) file.
@@ -22,13 +21,6 @@
2221
*/
2322
class ClassCacheCacheWarmer implements CacheWarmerInterface
2423
{
25-
private $classMatcher;
26-
27-
public function __construct(ClassMatcherInterface $classMatcher = null)
28-
{
29-
$this->classMatcher = $classMatcher;
30-
}
31-
3224
/**
3325
* Warms up the cache.
3426
*
@@ -46,14 +38,7 @@ public function warmUp($cacheDir)
4638
return;
4739
}
4840

49-
$classesToCompile = include $classmap;
50-
51-
if ($this->classMatcher) {
52-
$declaredClasses = array_keys(ClassCollectionLoader::getComposerClassMap());
53-
$classesToCompile = $this->classMatcher->match($declaredClasses, $classesToCompile);
54-
}
55-
56-
ClassCollectionLoader::load($classesToCompile, $cacheDir, 'classes', false);
41+
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false);
5742
}
5843

5944
/**

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,6 @@ public function load(array $configs, ContainerBuilder $container)
169169
$definition->replaceArgument(1, null);
170170
}
171171

172-
$this->addAnnotatedClassesToCompile(array(
173-
'**Bundle\\Controller\\',
174-
'**Bundle\\Entity\\',
175-
176-
// Added explicitly so that we dont rely on the class map being dumped to make it work
177-
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
178-
));
179-
180172
$this->addClassesToCompile(array(
181173
'Symfony\\Component\\Config\\FileLocator',
182174

@@ -203,6 +195,12 @@ public function load(array $configs, ContainerBuilder $container)
203195
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerNameParser',
204196
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
205197
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
198+
), array(
199+
'**Bundle\\Controller\\',
200+
'**Bundle\\Entity\\',
201+
202+
// Added explicitly so that we dont rely on the class map being dumped to make it work
203+
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
206204
));
207205
}
208206

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@
1818

1919
<service id="request_stack" class="Symfony\Component\HttpFoundation\RequestStack" />
2020

21-
<service id="kernel.class_cache.matcher" class="Symfony\Component\HttpKernel\CacheWarmer\ClassMatcher" public="false" />
22-
2321
<service id="cache_warmer" class="Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate">
2422
<argument type="collection" />
2523
</service>
2624

2725
<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer">
28-
<argument type="service" id="kernel.class_cache.matcher" />
2926
<tag name="kernel.cache_warmer" />
3027
</service>
3128

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=5.5.9",
2020
"symfony/asset": "~2.8|~3.0",
2121
"symfony/cache": "~3.1",
22-
"symfony/class-loader": "~3.2",
22+
"symfony/class-loader": "~2.8|~3.0",
2323
"symfony/dependency-injection": "~3.2",
2424
"symfony/config": "~2.8|~3.0",
2525
"symfony/event-dispatcher": "~2.8|~3.0",

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
use Composer\Autoload\ClassLoader;
15-
use Symfony\Component\Debug\DebugClassLoader;
16-
1714
/**
1815
* ClassCollectionLoader.
1916
*
@@ -25,32 +22,6 @@ class ClassCollectionLoader
2522
private static $seen;
2623
private static $useTokenizer = true;
2724

28-
/**
29-
* Return the Composer class map.
30-
*
31-
* @return array
32-
*/
33-
public static function getComposerClassMap()
34-
{
35-
$classes = array();
36-
37-
foreach (spl_autoload_functions() as $function) {
38-
if (!is_array($function)) {
39-
continue;
40-
}
41-
42-
if ($function[0] instanceof DebugClassLoader) {
43-
$function = $function[0]->getClassLoader();
44-
}
45-
46-
if (is_array($function) && $function[0] instanceof ClassLoader) {
47-
$classes += $function[0]->getClassMap();
48-
}
49-
}
50-
51-
return $classes;
52-
}
53-
5425
/**
5526
* Loads a list of classes and caches them in one big file.
5627
*

src/Symfony/Component/HttpKernel/CacheWarmer/ClassMatcher.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/Symfony/Component/HttpKernel/CacheWarmer/ClassMatcherInterface.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0