8000 removed the automatic loading of the compiled classes (should be done… · beenalee/symfony@4cbc33a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cbc33a

Browse files
committed
removed the automatic loading of the compiled classes (should be done explicitely by the end user now)
1 parent 3fe385e commit 4cbc33a

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass;
1818
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
20-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCachePass;
2120
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
2221
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
2322
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
@@ -27,7 +26,6 @@
2726
use Symfony\Component\DependencyInjection\Scope;
2827
use Symfony\Component\HttpFoundation\File\File;
2928
use Symfony\Component\HttpKernel\Bundle\Bundle;
30-
use Symfony\Component\ClassLoader\ClassCollectionLoader;
3129

3230
/**
3331
* Bundle.
@@ -41,15 +39,6 @@ class FrameworkBundle extends Bundle
4139
*/
4240
public function boot()
4341
{
44-
// load core classes
45-
ClassCollectionLoader::load(
46-
$this->container->getParameter('kernel.compiled_classes'),
47-
$this->container->getParameter('kernel.cache_dir'),
48-
'classes',
49-
$this->container->getParameter('kernel.debug'),
50-
true
51-
);
52-
5342
if ($this->container->has('error_handler')) {
5443
$this->container->get('error_handler');
5544
}
@@ -67,7 +56,6 @@ public function build(ContainerBuilder $container)
6756
$container->addCompilerPass(new TemplatingPass());
6857
$container->addCompilerPass(new AddConstraintValidatorsPass());
6958
$container->addCompilerPass(new FormPass());
70-
$container->addCompilerPass(new AddClassesToCachePass());
7159
$container->addCompilerPass(new TranslatorPass());
7260
$container->addCompilerPass(new AddCacheWarmerPass());
7361

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?php
22

3-
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
4-
5-
use Symfony\Component\DependencyInjection\ContainerBuilder;
6-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8-
93
/*
104
* This file is part of the Symfony framework.
115
*
@@ -15,6 +9,12 @@
159
* with this source code in the file LICENSE.
1610
*/
1711

12+
namespace Symfony\Component\HttpKernel\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17+
1818
/**
1919
* Sets the classes to compile in the cache for the container.
2020
*

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
2121
use Symfony\Component\DependencyInjection\Lo 8000 ader\PhpFileLoader;
2222
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
23+
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
2324
use Symfony\Component\HttpFoundation\Request;
2425
use Symfony\Component\HttpKernel\HttpKernelInterface;
2526
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
2627
use Symfony\Component\HttpKernel\Config\FileLocator;
2728
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
29+
use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass;
30+
use Symfony\Component\HttpKernel\DependencyInjection\Extension as DIExtension;
2831
use Symfony\Component\Config\Loader\LoaderResolver;
2932
use Symfony\Component\Config\Loader\DelegatingLoader;
3033
use Symfony\Component\Config\ConfigCache;
34+
use Symfony\Component\ClassLoader\ClassCollectionLoader;
3135

3236
/**
3337
* The Kernel is the heart of the Symfony system.
@@ -47,6 +51,7 @@ abstract class Kernel implements KernelInterface
4751
protected $booted;
4852
protected $name;
4953
protected $startTime;
54+
protected $classes;
5055

5156
const VERSION = '2.0.0-DEV';
5257

@@ -63,6 +68,7 @@ public function __construct($environment, $debug)
6368
$this->booted = false;
6469
$this->rootDir = $this->getRootDir();
6570
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
71+
$this->classes = array();
6672

6773
if ($this->debug) {
6874
ini_set('display_errors', 1);
@@ -332,6 +338,28 @@ public function getContainer()
332338
return $this->container;
333339
}
334340

341+
/**
342+
* Loads the PHP class cache.
343+
*
344+
* @param string $name The cache name prefix
345+
* @param string $extension File extension of the resulting file
346+
*/
347+
public function loadClassCache($name = 'classes', $extension = '.php')
348+
{
349+
if (!$ 3269 this->booted) {
350+
$this->boot();
351+
}
352+
353+
if ($this->classes) {
354+
ClassCollectionLoader::load($this->classes, $this->getCacheDir(), $name, $this->debug, true, $extension);
355+
}
356+
}
357+
358+
public function addClassesToCache(array $classes)
359+
{
360+
$this->classes = array_unique(array_merge($this->classes, $classes));
361+
}
362+
335363
/**
336364
* Gets the request start time (not available if debug is disabled).
337365
*
@@ -563,8 +591,11 @@ protected function buildContainer()
563591
}
564592
}
565593

594+
$container->addCompilerPass(new AddClassesToCachePass($this));
566595
$container->compile();
567596

597+
$this->addClassesToCache($container->getParameter('kernel.compiled_classes'));
598+
568599
return $container;
569600
}
570601

0 commit comments

Comments
 (0)
0