mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/13904] Modify constructor to be instantiatable by container
PHPBB3-13904
This commit is contained in:
parent
557f1a89d5
commit
c72d6a71bb
2 changed files with 32 additions and 13 deletions
|
@ -4,3 +4,7 @@ services:
|
||||||
|
|
||||||
files.filespec:
|
files.filespec:
|
||||||
class: phpbb\files\filespec
|
class: phpbb\files\filespec
|
||||||
|
arguments:
|
||||||
|
- @filesystem
|
||||||
|
- @mimetype.guesser
|
||||||
|
- @plupload
|
||||||
|
|
|
@ -33,7 +33,6 @@ class filespec
|
||||||
var $destination_path = '';
|
var $destination_path = '';
|
||||||
|
|
||||||
var $file_moved = false;
|
var $file_moved = false;
|
||||||
var $init_error = false;
|
|
||||||
var $local = false;
|
var $local = false;
|
||||||
|
|
||||||
var $error = array();
|
var $error = array();
|
||||||
|
@ -61,14 +60,19 @@ class filespec
|
||||||
* File Class
|
* File Class
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function filespec($upload_ary, $upload_namespace, \phpbb\filesystem\filesystem_interface $phpbb_filesystem, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
|
function filespec(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
|
||||||
{
|
{
|
||||||
if (!isset($upload_ary))
|
// @todo call this via files
|
||||||
{
|
//$this->set_upload_ary($upload_ary);
|
||||||
$this->init_error = true;
|
//$this->set_upload_namespace($upload_namespace);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$this->plupload = $plupload;
|
||||||
|
$this->mimetype_guesser = $mimetype_guesser;
|
||||||
|
$this->filesystem = $phpbb_filesystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_upload_ary($upload_ary)
|
||||||
|
{
|
||||||
$this->filename = $upload_ary['tmp_name'];
|
$this->filename = $upload_ary['tmp_name'];
|
||||||
$this->filesize = $upload_ary['size'];
|
$this->filesize = $upload_ary['size'];
|
||||||
$name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name'];
|
$name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name'];
|
||||||
|
@ -93,10 +97,21 @@ class filespec
|
||||||
$this->file_moved = false;
|
$this->file_moved = false;
|
||||||
|
|
||||||
$this->local = (isset($upload_ary['local_mode'])) ? true : false;
|
$this->local = (isset($upload_ary['local_mode'])) ? true : false;
|
||||||
$this->upload = $upload_namespace;
|
}
|
||||||
$this->plupload = $plupload;
|
|
||||||
$this->mimetype_guesser = $mimetype_guesser;
|
public function set_upload_namespace($namespace)
|
||||||
$this->filesystem = $phpbb_filesystem;
|
{
|
||||||
|
$this->upload = $namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if class members were not properly initalised yet
|
||||||
|
*
|
||||||
|
* @return bool True if there was an init error, false if not
|
||||||
|
*/
|
||||||
|
protected function init_error()
|
||||||
|
{
|
||||||
|
return !isset($upload_ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +124,7 @@ class filespec
|
||||||
*/
|
*/
|
||||||
function clean_filename($mode = 'unique', $prefix = '', $user_id = '')
|
function clean_filename($mode = 'unique', $prefix = '', $user_id = '')
|
||||||
{
|
{
|
||||||
if ($this->init_error)
|
if ($this->init_error())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +169,7 @@ class filespec
|
||||||
*/
|
*/
|
||||||
function get($property)
|
function get($property)
|
||||||
{
|
{
|
||||||
if ($this->init_error || !isset($this->$property))
|
if ($this->init_error() || !isset($this->$property))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue