mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/extension-manager] Prepend the phpbb_root_path if necessary.
PHPBB3-10323
This commit is contained in:
parent
fd42599191
commit
7d16007d6a
2 changed files with 27 additions and 8 deletions
|
@ -205,7 +205,7 @@ class phpbb_extension_finder
|
||||||
$this->query['suffix'] .= $this->phpEx;
|
$this->query['suffix'] .= $this->phpEx;
|
||||||
$this->query['default_suffix'] .= $this->phpEx;
|
$this->query['default_suffix'] .= $this->phpEx;
|
||||||
|
|
||||||
$files = $this->get_files($cache);
|
$files = $this->find($cache, false);
|
||||||
|
|
||||||
$classes = array();
|
$classes = array();
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
|
@ -225,7 +225,7 @@ class phpbb_extension_finder
|
||||||
*/
|
*/
|
||||||
public function get_directories($cache = true)
|
public function get_directories($cache = true)
|
||||||
{
|
{
|
||||||
return $this->find($cache, true);
|
return $this->find_with_root_path($cache, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,7 +236,27 @@ class phpbb_extension_finder
|
||||||
*/
|
*/
|
||||||
public function get_files($cache = true)
|
public function get_files($cache = true)
|
||||||
{
|
{
|
||||||
return $this->find($cache, false);
|
return $this->find_with_root_path($cache, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper around the general find which prepends a root path to results
|
||||||
|
*
|
||||||
|
* @param bool $cache Whether the result should be cached
|
||||||
|
* @param bool $is_dir Whether the found items should be directories
|
||||||
|
* @return array An array of paths to found items
|
||||||
|
*/
|
||||||
|
protected function find_with_root_path($cache = true, $is_dir = false)
|
||||||
|
{
|
||||||
|
$items = $this->find($cache, $is_dir);
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach ($items as $item)
|
||||||
|
{
|
||||||
|
$result[] = $this->phpbb_root_path . $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,7 +63,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
|
|
||||||
sort($dirs);
|
sort($dirs);
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(array(
|
||||||
'ext/foo/type/',
|
dirname(__FILE__) . '/ext/foo/type/',
|
||||||
), $dirs);
|
), $dirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
public function test_get_classes_create_cache()
|
public function test_get_classes_create_cache()
|
||||||
{
|
{
|
||||||
$cache = new phpbb_mock_cache;
|
$cache = new phpbb_mock_cache;
|
||||||
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/includes/', $cache, '.php', '_custom_cache_name');
|
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
|
||||||
$files = $finder->suffix('_class.php')->get_files();
|
$files = $finder->suffix('_class.php')->get_files();
|
||||||
|
|
||||||
sort($files);
|
sort($files);
|
||||||
|
@ -159,7 +159,6 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
'is_dir' => false,
|
'is_dir' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected_files, $files);
|
|
||||||
$cache->checkAssociativeVar($this, '_custom_cache_name', array(
|
$cache->checkAssociativeVar($this, '_custom_cache_name', array(
|
||||||
md5(serialize($query)) => $expected_files,
|
md5(serialize($query)) => $expected_files,
|
||||||
));
|
));
|
||||||
|
@ -178,7 +177,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
'is_dir' => false,
|
'is_dir' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/includes/', new phpbb_mock_cache(array(
|
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', new phpbb_mock_cache(array(
|
||||||
'_ext_finder' => array(
|
'_ext_finder' => array(
|
||||||
md5(serialize($query)) => array('file_name'),
|
md5(serialize($query)) => array('file_name'),
|
||||||
),
|
),
|
||||||
|
@ -191,7 +190,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
|
|
||||||
sort($classes);
|
sort($classes);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('file_name'),
|
array(dirname(__FILE__) . '/file_name'),
|
||||||
$classes
|
$classes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue