1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

DDC-1698 - Allow autoload registration from a Configuration instance

This commit is contained in:
Benjamin Eberlei 2013-01-06 11:07:19 +01:00
parent 7dfe0cae08
commit ce290bc99b

View file

@ -19,6 +19,9 @@
namespace Doctrine\ORM\Proxy; namespace Doctrine\ORM\Proxy;
use Doctrine\ORM\Configuration;
use Closure;
/** /**
* Special Autoloader for Proxy classes because them not being PSR-0 compatible. * Special Autoloader for Proxy classes because them not being PSR-0 compatible.
* *
@ -61,7 +64,7 @@ class Autoloader
* *
* @return \Closure * @return \Closure
*/ */
static public function register($proxyDir, $proxyNamespace, \Closure $notFoundCallback = null) static public function register($proxyDir, $proxyNamespace, Closure $notFoundCallback = null)
{ {
$proxyNamespace = ltrim($proxyNamespace, "\\"); $proxyNamespace = ltrim($proxyNamespace, "\\");
$autoloader = function($className) use ($proxyDir, $proxyNamespace, $notFoundCallback) { $autoloader = function($className) use ($proxyDir, $proxyNamespace, $notFoundCallback) {
@ -80,4 +83,18 @@ class Autoloader
return $autoloader; return $autoloader;
} }
/**
* Registers and returns autoloader callback from a Configuration instance
*
* @param Configuration $config
* @param \Closure $notFoundCallback
*
* @return \Closure
*/
static public function registerFromConfiguration(Configuration $configuration, Closure $notFoundCallback)
{
return self::register($configuration->getProxyDir(), $configuration->getProxyNamespace(), $notFoundCallback);
}
} }