diff --git a/phpBB/config/default/container/services_storage.yml b/phpBB/config/default/container/services_storage.yml index 7d004ec9c6..83b013a1c2 100644 --- a/phpBB/config/default/container/services_storage.yml +++ b/phpBB/config/default/container/services_storage.yml @@ -2,8 +2,10 @@ services: storage.adapter.avatar: class: phpbb\storage\adapter\local arguments: + - '@config' - '@filesystem' - '%core.root_path%' + - 'avatar_path' storage.avatar: class: phpbb\storage\storage arguments: diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php index b2d8c58d36..00b51c64f0 100644 --- a/phpBB/phpbb/storage/adapter/local.php +++ b/phpBB/phpbb/storage/adapter/local.php @@ -25,16 +25,21 @@ class local implements adapter_interface */ protected $filesystem; - /** @var string phpBB root path */ - protected $phpbb_root_path; + /** @var string path */ + protected $root_path; /** * Constructor */ - public function __construct($filesystem, $phpbb_root_path) + public function __construct(\phpbb\config\config $config, \phpbb\filesystem\filesystem $filesystem, $root_path, $path_key) { $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; + $this->root_path = $root_path.$config[$path_key]; + + if(substr($this->root_path, -1, 1) != DIRECTORY_SEPARATOR) + { + $this->root_path = $this->root_path.DIRECTORY_SEPARATOR; + } } /** @@ -42,14 +47,14 @@ class local implements adapter_interface */ public function put_contents($path, $content) { - if ($this->exists($this->phpbb_root_path.$path)) + if ($this->exists($this->root_path.$path)) { throw new exception('', $path); // FILE_EXISTS } try { - $this->filesystem->dump_file($this->phpbb_root_path.$path, $content); + $this->filesystem->dump_file($this->root_path.$path, $content); } catch (filesystem_exception $e) { @@ -62,12 +67,12 @@ class local implements adapter_interface */ public function get_contents($path) { - if (!$this->exists($this->phpbb_root_path.$path)) + if (!$this->exists($this->root_path.$path)) { throw new exception('', $path); // FILE_DONT_EXIST } - if (($content = @file_get_contents($this->phpbb_root_path.$path)) === false) + if (($content = @file_get_contents($this->root_path.$path)) === false) { throw new exception('', $path); // CANNOT READ FILE } @@ -80,7 +85,7 @@ class local implements adapter_interface */ public function exists($path) { - return $this->filesystem->exists($this->phpbb_root_path.$path); + return $this->filesystem->exists($this->root_path.$path); } /** @@ -90,7 +95,7 @@ class local implements adapter_interface { try { - $this->filesystem->remove($this->phpbb_root_path.$path); + $this->filesystem->remove($this->root_path.$path); } catch (filesystem_exception $e) { @@ -105,7 +110,7 @@ class local implements adapter_interface { try { - $this->filesystem->rename($this->phpbb_root_path.$path_orig, $this->phpbb_root_path.$path_dest, false); + $this->filesystem->rename($this->root_path.$path_orig, $this->root_path.$path_dest, false); } catch (filesystem_exception $e) { @@ -120,7 +125,7 @@ class local implements adapter_interface { try { - $this->filesystem->copy($this->phpbb_root_path.$path_orig, $this->phpbb_root_path.$path_dest, false); + $this->filesystem->copy($this->root_path.$path_orig, $this->root_path.$path_dest, false); } catch (filesystem_exception $e) { @@ -135,7 +140,7 @@ class local implements adapter_interface { try { - $this->filesystem->mkdir($this->phpbb_root_path.$path); + $this->filesystem->mkdir($this->root_path.$path); } catch (filesystem_exception $e) { diff --git a/phpBB/phpbb/storage/controller.php b/phpBB/phpbb/storage/controller.php deleted file mode 100644 index 22f733faf7..0000000000 --- a/phpBB/phpbb/storage/controller.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\storage; - -class controller -{ - /** - * @var ContainerInterface - */ - protected $container; - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - public function get_file($storage, $file) - { - $storage = $this->container->get($storage); - - return $storage->get_contents($file); - } -}