[feature/dic] Use DIC in download/file and install/index

PHPBB3-10739
This commit is contained in:
Igor Wiedler 2012-03-31 20:45:58 +02:00
parent 873630f04e
commit a7f61b91b7
2 changed files with 38 additions and 25 deletions

View file

@ -14,7 +14,6 @@ define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1); $phpEx = substr(strrchr(__FILE__, '.'), 1);
// Thank you sun. // Thank you sun.
if (isset($_SERVER['CONTENT_TYPE'])) if (isset($_SERVER['CONTENT_TYPE']))
{ {
@ -45,20 +44,27 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('parameters.yml');
$loader->load('services.yml');
$container->setParameter('core.root_path', $phpbb_root_path);
$container->setParameter('core.php_ext', $phpEx);
$phpbb_class_loader_ext = $container->get('class_loader.ext');
$phpbb_class_loader_ext->register(); $phpbb_class_loader_ext->register();
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); $phpbb_class_loader = $container->get('class_loader');
$phpbb_class_loader->register(); $phpbb_class_loader->register();
// set up caching // set up caching
$cache_factory = new phpbb_cache_factory($acm_type); $cache = $container->get('cache');
$cache = $cache_factory->get_service(); $phpbb_class_loader_ext->set_cache($container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($container->get('cache.driver'));
$phpbb_class_loader->set_cache($cache->get_driver());
$phpbb_dispatcher = new phpbb_event_dispatcher(); $phpbb_dispatcher = $container->get('dispatcher');
$request = new phpbb_request(); $request = $container->get('request');
$db = new $sql_db(); $db = $container->get('dbal.conn');
// Connect to DB // Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
@ -69,19 +75,18 @@ if (isset($_GET['avatar']))
request_var('', 0, false, false, $request); request_var('', 0, false, false, $request);
// worst-case default $config = $container->get('config');
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
set_config(null, null, null, $config); set_config(null, null, null, $config);
set_config_count(null, null, null, $config); set_config_count(null, null, null, $config);
// load extensions // load extensions
$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); $phpbb_extension_manager = $container->get('ext.manager');
$phpbb_subscriber_loader = $container->get('event.subscriber_loader');
$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
$phpbb_subscriber_loader->load(); $phpbb_subscriber_loader->load();
// worst-case default
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
$filename = request_var('avatar', ''); $filename = request_var('avatar', '');
$avatar_group = false; $avatar_group = false;
$exit = false; $exit = false;

View file

@ -79,19 +79,27 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('parameters.yml');
$loader->load('services.yml');
$container->setParameter('core.root_path', $phpbb_root_path);
$container->setParameter('core.php_ext', $phpEx);
$container->setAlias('cache.driver.install', 'cache.driver');
$phpbb_class_loader_ext = $container->get('class_loader.ext');
$phpbb_class_loader_ext->register(); $phpbb_class_loader_ext->register();
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); $phpbb_class_loader = $container->get('class_loader');
$phpbb_class_loader->register(); $phpbb_class_loader->register();
// set up caching // set up caching
$cache_factory = new phpbb_cache_factory('file'); $cache = $container->get('cache');
$cache = $cache_factory->get_service(); $phpbb_class_loader_ext->set_cache($container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($container->get('cache.driver'));
$phpbb_class_loader->set_cache($cache->get_driver());
$phpbb_dispatcher = new phpbb_event_dispatcher(); $phpbb_dispatcher = $container->get('dispatcher');
$request = new phpbb_request(); $request = $container->get('request');
// make sure request_var uses this request instance // make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function request_var('', 0, false, false, $request); // "dependency injection" for a function