add aliasing autoloader supporting old namespace

This commit is contained in:
Toni Uebernickel 2016-02-15 22:33:58 +01:00
parent bb85f75008
commit 9402959f26
3 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<?php
namespace Propel\Bundle\PropelBundle\Tests;
class AutoloadAliasTest extends \PHPUnit_Framework_TestCase
{
public function testOldNamespaceWorks()
{
$inflector = new \Propel\PropelBundle\Util\PropelInflector();
static::assertInstanceOf('Propel\PropelBundle\Util\PropelInflector', $inflector);
static::assertInstanceOf('Propel\Bundle\PropelBundle\Util\PropelInflector', $inflector);
}
}

9
autoload_aliases.php Normal file
View file

@ -0,0 +1,9 @@
<?php
function autoload_propel_aliases($className) {
if (0 === strpos($className, 'Propel\PropelBundle')) {
class_alias(str_replace('Propel\PropelBundle', 'Propel\Bundle\PropelBundle', $className), $className);
}
}
spl_autoload_register('autoload_propel_aliases', false, true);

View file

@ -11,6 +11,7 @@
"autoload": {
"psr-4": { "Propel\\Bundle\\PropelBundle\\": "" },
"files": ["autoload_aliases.php"],
"exclude-from-classmap": [ "Tests/" ]
},