primo commit
This commit is contained in:
35
libraries/regularlabs/src/Layout.php
Normal file
35
libraries/regularlabs/src/Layout.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Regular Labs Library
|
||||
* @version 24.11.1459
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link https://regularlabs.com
|
||||
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
namespace RegularLabs\Library;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
use Joomla\CMS\Layout\FileLayout as JFileLayout;
|
||||
class Layout
|
||||
{
|
||||
static $layouts = [];
|
||||
public static function get($layout_id, $layout_path, $extension)
|
||||
{
|
||||
$key = $extension . '.' . $layout_id;
|
||||
if (isset(self::$layouts[$key])) {
|
||||
return self::$layouts[$key];
|
||||
}
|
||||
$layout = new JFileLayout($layout_id);
|
||||
$default_paths = $layout->getDefaultIncludePaths();
|
||||
$default_paths = array_reverse($default_paths);
|
||||
$layout->addIncludePath($layout_path);
|
||||
foreach ($default_paths as $path) {
|
||||
$layout->addIncludePath($path . '/' . $extension);
|
||||
}
|
||||
self::$layouts[$key] = $layout;
|
||||
return self::$layouts[$key];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user