removed the Autoloader as Composer provide one

This commit is contained in:
Fabien Potencier
2015-01-20 03:21:18 +01:00
parent 73311f1fb6
commit 886b863dcb
7 changed files with 5 additions and 88 deletions
+3
View File
@@ -19,6 +19,9 @@ before_script:
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && sudo make install"; fi
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
install:
- travis_retry composer install --no-interaction
matrix:
exclude:
- php: hhvm
+1 -2
View File
@@ -21,8 +21,7 @@ are in use.
The simplest way to configure Twig to load templates for your application
looks roughly like this::
require_once '/path/to/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
require_once '/path/to/vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment($loader, array(
-7
View File
@@ -72,10 +72,3 @@ filesystem loader::
));
echo $twig->render('index.html', array('name' => 'Fabien'));
.. tip::
If you are not using Composer, use the Twig built-in autoloader::
require_once '/path/to/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
-44
View File
@@ -1,44 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Autoloads Twig classes.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_Autoloader
{
/**
* Registers Twig_Autoloader as an SPL autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not.
*/
public static function register($prepend = false)
{
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
}
/**
* Handles autoloading of classes.
*
* @param string $class A class name.
*/
public static function autoload($class)
{
if (0 !== strpos($class, 'Twig')) {
return;
}
if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
require $file;
}
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="test/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Twig Test Suite">
-21
View File
@@ -1,21 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase
{
public function testAutoload()
{
$this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');
$autoloader = new Twig_Autoloader();
$this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class');
}
}
-13
View File
@@ -1,13 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__.'/../lib/Twig/Autoloader.php';
Twig_Autoloader::register(true);