mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[feature/merging-style-components] Changing path provider
Changing set_templates() to set_style() and removing second parameter, changing get_main_template_path() to get_main_style_path(), removing template_root_for_style(), updating docblocks PHPBB3-10632
This commit is contained in:
@@ -16,15 +16,15 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a template locator with paths
|
||||
* Provides a style resource locator with paths
|
||||
*
|
||||
* Finds installed template paths and makes them available to the locator.
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface
|
||||
{
|
||||
protected $main_template_name = '';
|
||||
protected $main_style_name = '';
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
@@ -38,62 +38,34 @@ class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_p
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the current template names and paths
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* The first element of the passed templates map, is considered the main
|
||||
* template and can be retrieved through get_main_template_path().
|
||||
* The first element of the passed styles map, is considered the main
|
||||
* style and can be retrieved through get_main_style_path().
|
||||
*
|
||||
* @param array $templates An associative map from template names to paths.
|
||||
* The first element is the main template.
|
||||
* If the path is false, it will be generated from
|
||||
* the supplied name.
|
||||
* @param string $style_root_path The root directory for styles identified
|
||||
* by name only.
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_templates(array $templates, $style_root_path)
|
||||
public function set_styles(array $styles)
|
||||
{
|
||||
$this->paths = array();
|
||||
|
||||
foreach ($templates as $name => $path)
|
||||
{
|
||||
if (!$path)
|
||||
{
|
||||
$path = $style_root_path . $this->template_root_for_style($name);
|
||||
}
|
||||
|
||||
$this->paths[] = $path;
|
||||
}
|
||||
|
||||
$this->main_template_path = $this->paths[0];
|
||||
$this->paths = $styles;
|
||||
$this->main_style_path = $this->paths[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the path to the main template passed into set_templates()
|
||||
* Retrieves the path to the main style passed into set_styles()
|
||||
*
|
||||
* @return string Main template path
|
||||
* @return string Main style path
|
||||
*/
|
||||
public function get_main_template_path()
|
||||
public function get_main_style_path()
|
||||
{
|
||||
return $this->main_template_path;
|
||||
return $this->main_style_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a style name to relative (to board root or extension) path to
|
||||
* the style's template files.
|
||||
* Retrieve an iterator over all style paths
|
||||
*
|
||||
* @param $style_name string Style name
|
||||
* @return string Path to style template files
|
||||
*/
|
||||
private function template_root_for_style($style_name)
|
||||
{
|
||||
return 'styles/' . $style_name . '/template';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an iterator over all template paths
|
||||
*
|
||||
* @return ArrayIterator An iterator for the array of template paths
|
||||
* @return ArrayIterator An iterator for the array of style paths
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
|
Reference in New Issue
Block a user