Update base and bootstrap

This commit is contained in:
Romain Neutron
2012-09-21 14:38:50 +02:00
parent 9cf8055d49
commit 3e13cb455c
4 changed files with 160 additions and 184 deletions

View File

@@ -8,10 +8,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../Alchemy/Phrasea/Core.php';
use Alchemy\Phrasea\Core;
use Symfony\Component\HttpFoundation\Request;
use Alchemy\Phrasea\Loader\Autoloader;
use Alchemy\Phrasea\Loader\CacheAutoloader;
/**
*
@@ -20,53 +19,62 @@ use Symfony\Component\HttpFoundation\Request;
*/
class bootstrap
{
protected static $core;
protected static $autoloader_initialized;
public static function set_php_configuration()
public static function register_autoloads($cacheAutoload = false)
{
return Core::initPHPConf();
}
/**
*
* @param $env
* @return Alchemy\Phrasea\Core
*/
public static function execute($env = null)
{
if (static::$core) {
return static::$core;
if (static::$autoloader_initialized) {
return;
}
static::$core = new Core($env);
require_once __DIR__ . '/../Alchemy/Phrasea/Loader/Autoloader.php';
require_once __DIR__ . '/../Alchemy/Phrasea/Loader/Autoloader.php';
$request = Request::createFromGlobals();
if ($cacheAutoload === true) {
try {
require_once __DIR__ . '/../Alchemy/Phrasea/Loader/CacheAutoloader.php';
if ( ! ! stripos($request->server->get('HTTP_USER_AGENT'), 'flash') && $request->getRequestUri() === '/prod/upload/') {
if (null !== $sessionId = $request->get('php_session_id')) {
session_id($sessionId);
$prefix = 'class_';
$namespace = md5(__DIR__);
$loader = new CacheAutoloader($prefix, $namespace);
} catch (\Exception $e) {
//no op code cache available
$loader = new Autoloader();
}
} else {
$loader = new Autoloader();
}
$getComposerNamespaces = function() {
return require realpath(__DIR__ . '/../../vendor/composer/autoload_namespaces.php');
};
foreach ($getComposerNamespaces() as $prefix => $path) {
if (substr($prefix, -1) === '_' || $prefix == 'Pimple') {
$loader->registerPrefix($prefix, $path);
} else {
$loader->registerNamespace($prefix, $path);
}
}
if (\setup::is_installed()) {
$gatekeeper = \gatekeeper::getInstance(static::$core);
$gatekeeper->check_directory($request);
}
$loader->registerNamespaces(array(
'Entities' => realpath(__DIR__ . '/../Doctrine/'),
'Repositories' => realpath(__DIR__ . '/../Doctrine/'),
'Proxies' => realpath(__DIR__ . '/../Doctrine/'),
'Doctrine\\Logger' => realpath(__DIR__ . '/../'),
'Types' => realpath(__DIR__ . "/../Doctrine"),
'PhraseaFixture' => realpath(__DIR__ . "/../conf.d"),
));
return static::$core;
}
$loader->register();
/**
*
* @return Alchemy\Phrasea\Core
*/
public static function getCore()
{
return static::$core;
}
set_include_path(
get_include_path() . PATH_SEPARATOR . realpath(__DIR__ . '/../../vendor/zend/gdata/library')
);
public static function register_autoloads()
{
return Core::initAutoloads();
static::$autoloader_initialized = true;
return;
}
}