removed the autoloader map feature

This feature added complexity to the framework but wasn't used in the core anyway.
You can still use the Map class loader  in your application though. But most of the time, using the APC
autoloader is just better.
This commit is contained in:
Fabien Potencier 2011-04-28 13:36:52 +02:00
parent 509f3dd454
commit 3fe385e4fb
5 changed files with 0 additions and 140 deletions

View File

@ -1,66 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Generates an autoload class map cache.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ClassMapCacheWarmer extends CacheWarmer
{
protected $container;
/**
* Constructor.
*
* @param ContainerInterface $container The container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Warms up the cache.
*
* @param string $cacheDir The cache directory
*/
public function warmUp($cacheDir)
{
if (!$this->container->hasParameter('kernel.autoload_classes')) {
return;
}
$classes = array();
foreach ($this->container->getParameter('kernel.autoload_classes') as $class) {
$r = new \ReflectionClass($class);
$classes[$class] = $r->getFilename();
}
$this->writeCacheFile($cacheDir.'/autoload.php', sprintf('<?php return %s;', var_export($classes, true)));
}
/**
* Checks whether this warmer is optional or not.
*
* @return Boolean always false
*/
public function isOptional()
{
return true;
}
}

View File

@ -1,39 +0,0 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* Sets the class map for the autoloader.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class AddClassesToAutoloadMapPass implements CompilerPassInterface
{
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$classes = array();
foreach ($container->getExtensions() as $extension) {
if ($extension instanceof Extension) {
$classes = array_merge($classes, $extension->getAutoloadClassMap());
}
}
$container->setParameter('kernel.autoload_classes', array_unique($classes));
}
}

View File

@ -18,7 +18,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelLi
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCachePass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToAutoloadMapPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
@ -29,7 +28,6 @@ use Symfony\Component\DependencyInjection\Scope;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\ClassLoader\MapFileClassLoader;
/**
* Bundle.
@ -55,11 +53,6 @@ class FrameworkBundle extends Bundle
if ($this->container->has('error_handler')) {
$this->container->get('error_handler');
}
if (file_exists($this->container->getParameter('kernel.cache_dir').'/autoload.php')) {
$classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir').'/autoload.php');
$classloader->register(true);
}
}
public function build(ContainerBuilder $container)
@ -75,7 +68,6 @@ class FrameworkBundle extends Bundle
$container->addCompilerPass(new AddConstraintValidatorsPass());
$container->addCompilerPass(new FormPass());
$container->addCompilerPass(new AddClassesToCachePass());
$container->addCompilerPass(new AddClassesToAutoloadMapPass());
$container->addCompilerPass(new TranslatorPass());
$container->addCompilerPass(new AddCacheWarmerPass());

View File

@ -10,7 +10,6 @@
<parameter key="error_handler.class">Symfony\Component\HttpKernel\Debug\ErrorHandler</parameter>
<parameter key="filesystem.class">Symfony\Component\HttpKernel\Util\Filesystem</parameter>
<parameter key="cache_warmer.class">Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate</parameter>
<parameter key="cache_warmer.autoloader_map.class">Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassMapCacheWarmer</parameter>
<parameter key="file_locator.class">Symfony\Component\HttpKernel\Config\FileLocator</parameter>
</parameters>
@ -33,11 +32,6 @@
<argument type="collection" />
</service>
<service id="cache_warmer.autoload_map" class="%cache_warmer.autoloader_map.class%" public="false">
<tag name="kernel.cache_warmer" />
<argument type="service" id="service_container" />
</service>
<!--
If you want to change the Request class, modify the code in
your front controller (app.php) so that it passes an instance of

View File

@ -23,7 +23,6 @@ use Symfony\Component\DependencyInjection\Container;
abstract class Extension implements ExtensionInterface
{
private $classes = array();
private $classMap = array();
/**
* Gets the classes to cache.
@ -45,26 +44,6 @@ abstract class Extension implements ExtensionInterface
$this->classes = array_merge($this->classes, $classes);
}
/**
* Gets the autoload class map.
*
* @return array An array of classes
*/
public function getAutoloadClassMap()
{
return $this->classMap;
}
/**
* Adds classes to the autoload class map.
*
* @param array $classes An array of classes
*/
public function addClassesToAutoloadMap(array $classes)
{
$this->classMap = array_merge($this->classMap, $classes);
}
/**
* Returns the base path for the XSD files.
*