move Thelia namespace into core/lib directory
introduce prod / dev environment
This commit is contained in:
43
core/lib/Thelia/Autoload/TheliaApcUniversalClassLoader.php
Normal file
43
core/lib/Thelia/Autoload/TheliaApcUniversalClassLoader.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Autoload;
|
||||
|
||||
class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
|
||||
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Come from Symfony\Component\ClassLoader\ApcUniversalClassLoader
|
||||
*
|
||||
* @param string $prefix
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($prefix) {
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* Come from Symfony\Component\ClassLoader\ApcUneiversalClassLoader
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class) {
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user