Ejemplo n.º 1
0
 /**
  * Loads a specific configuration.
  *
  * @param array            $configs   An array of configuration values
  * @param ContainerBuilder $container A ContainerBuilder instance
  *
  * @throws \InvalidArgumentException When provided tag is not defined in this extension
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $filesystem = new \phpbb\filesystem\filesystem();
     $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path)));
     $loader->load($container->getParameter('core.environment') . '/container/environment.yml');
     $config = $this->getConfiguration($configs, $container);
     $config = $this->processConfiguration($config, $configs);
     if ($config['require_dev_dependencies']) {
         if (!class_exists('Goutte\\Client', true)) {
             trigger_error('Composer development dependencies have not been set up for the ' . $container->getParameter('core.environment') . ' environment yet, run ' . "'php ../composer.phar install --dev' from the phpBB directory to do so.", E_USER_ERROR);
         }
     }
     // Set the Twig options if defined in the environment
     $definition = $container->getDefinition('template.twig.environment');
     $twig_environment_options = $definition->getArgument(7);
     if ($config['twig']['debug']) {
         $twig_environment_options['debug'] = true;
     }
     if ($config['twig']['auto_reload']) {
         $twig_environment_options['auto_reload'] = true;
     }
     // Replace the 8th argument, the options passed to the environment
     $definition->replaceArgument(7, $twig_environment_options);
     if ($config['twig']['enable_debug_extension']) {
         $definition = $container->getDefinition('template.twig.extensions.debug');
         $definition->addTag('twig.extension');
     }
     // Set the debug options
     foreach ($config['debug'] as $name => $value) {
         $container->setParameter('debug.' . $name, $value);
     }
 }
Ejemplo n.º 2
0
/**
* Removes absolute path to phpBB root directory from error messages
* and converts backslashes to forward slashes.
*
* @param string $errfile	Absolute file path
*							(e.g. /var/www/phpbb3/phpBB/includes/functions.php)
*							Please note that if $errfile is outside of the phpBB root,
*							the root path will not be found and can not be filtered.
* @return string			Relative file path
*							(e.g. /includes/functions.php)
*/
function phpbb_filter_root_path($errfile)
{
    global $phpbb_filesystem;
    static $root_path;
    if (empty($root_path)) {
        if ($phpbb_filesystem) {
            $root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../');
        } else {
            $filesystem = new \phpbb\filesystem\filesystem();
            $root_path = $filesystem->realpath(dirname(__FILE__) . '/../');
        }
    }
    return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile);
}
Ejemplo n.º 3
0
 protected function load_services(ContainerBuilder $container)
 {
     $filesystem = new \phpbb\filesystem\filesystem();
     $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->ext_path)));
     $loader->load('environment.yml');
 }
Ejemplo n.º 4
0
 /**
  * Loads the services.yml file.
  *
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 protected function load_services(ContainerBuilder $container)
 {
     $services_directory = false;
     $services_file = false;
     if (file_exists($this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/environment.yml')) {
         $services_directory = $this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/';
         $services_file = 'environment.yml';
     } else {
         if (!is_dir($this->ext_path . 'config/' . $container->getParameter('core.environment'))) {
             if (file_exists($this->ext_path . 'config/default/container/environment.yml')) {
                 $services_directory = $this->ext_path . 'config/default/container/';
                 $services_file = 'environment.yml';
             } else {
                 if (!is_dir($this->ext_path . 'config/default') && file_exists($this->ext_path . '/config/services.yml')) {
                     $services_directory = $this->ext_path . 'config';
                     $services_file = 'services.yml';
                 }
             }
         }
     }
     if ($services_directory && $services_file) {
         $filesystem = new \phpbb\filesystem\filesystem();
         $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($services_directory)));
         $loader->load($services_file);
     }
 }