示例#1
0
 /**
  * Build dependency injection container
  *
  * @throws \phpbb\install\exception\cannot_build_container_exception	When container cannot be built
  */
 protected function build_container()
 {
     // If the container has been already built just return.
     // Although this should never happen
     if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) {
         return;
     }
     // Check whether container can be built
     // We need config.php for that so let's check if it has been set up yet
     if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) {
         throw new cannot_build_container_exception();
     }
     $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext);
     $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext);
     // For BC with functions that we need during install
     global $phpbb_container, $table_prefix;
     $disable_super_globals = $this->request->super_globals_disabled();
     // This is needed because container_builder::get_env_parameters() uses $_SERVER
     if ($disable_super_globals) {
         $this->request->enable_super_globals();
     }
     $other_config_path = $this->phpbb_root_path . 'install/update/new/config';
     $config_path = is_dir($other_config_path) ? $other_config_path : $this->phpbb_root_path . 'config';
     $this->container = $phpbb_container_builder->with_environment('production')->with_config($phpbb_config_php_file)->with_config_path($config_path)->without_compiled_container()->get_container();
     // Setting request is required for the compatibility globals as those are generated from
     // this container
     if (!$this->container->isFrozen()) {
         $this->container->register('request')->setSynthetic(true);
         $this->container->register('language')->setSynthetic(true);
     }
     $this->container->set('request', $this->request);
     $this->container->set('language', $this->language);
     $this->container->compile();
     $phpbb_container = $this->container;
     $table_prefix = $phpbb_config_php_file->get('table_prefix');
     // Restore super globals to previous state
     if ($disable_super_globals) {
         $this->request->disable_super_globals();
     }
     // Get compatibilty globals and constants
     $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext);
     register_compatibility_globals();
     $this->update_helper->include_file('includes/constants.' . $this->php_ext);
 }
示例#2
0
文件: phpbbcli.php 项目: bantu/phpbb
require $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
$phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file);
$input = new ArgvInput();
if ($input->hasParameterOption(array('--env'))) {
    $phpbb_container_builder->with_environment($input->getParameterOption('--env'));
}
if ($input->hasParameterOption(array('--safe-mode'))) {
    $phpbb_container_builder->without_extensions();
    $phpbb_container_builder->without_cache();
} else {
    $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
    $phpbb_class_loader_ext->register();
}
$phpbb_container = $phpbb_container_builder->get_container();
$phpbb_container->get('request')->enable_super_globals();
require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx;
register_compatibility_globals();
/* @var $user \phpbb\user */
$user = $phpbb_container->get('user');
$user->data['user_id'] = ANONYMOUS;
$user->ip = '127.0.0.1';
$user->add_lang('acp/common');
$user->add_lang('cli');
/* @var $lang \phpbb\language\language */
$lang = $phpbb_container->get('language');
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $lang);
$application->setDispatcher($phpbb_container->get('dispatcher'));
$application->register_container_commands($phpbb_container->get('console.command_collection'));
$application->run($input);