Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/src/MVC/Model/BaseDatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\LegacyFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryAwareTrait;
Expand Down
57 changes: 57 additions & 0 deletions libraries/src/MVC/Model/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

\defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Object\CMSObject;

Expand All @@ -31,6 +32,14 @@ abstract class BaseModel extends CMSObject implements ModelInterface, StatefulMo
*/
protected $name;

/**
* The include paths
*
* @var array
* @since 4.0.0
*/
protected static $paths;

/**
* Constructor
*
Expand Down Expand Up @@ -67,6 +76,54 @@ public function __construct($config = array())
}
}

/**
* Add a directory where \JModelLegacy should search for models. You may
* either pass a string or an array of directories.
*
* @param mixed $path A path or array[sting] of paths to search.
* @param string $prefix A prefix for models.
*
* @return array An array with directory elements. If prefix is equal to '', all directories are returned.
*
* @since 3.0
* @deprecated 5.0 See LeagcyModelLoaderTrait\getInstance
*/
public static function addIncludePath($path = '', $prefix = '')
{
if (!isset(self::$paths))
{
self::$paths = array();
}

if (!isset(self::$paths[$prefix]))
{
self::$paths[$prefix] = array();
}

if (!isset(self::$paths['']))
{
self::$paths[''] = array();
}

if (!empty($path))
{
foreach ((array) $path as $includePath)
{
if (!\in_array($includePath, self::$paths[$prefix]))
{
array_unshift(self::$paths[$prefix], Path::clean($includePath));
}

if (!\in_array($includePath, self::$paths['']))
{
array_unshift(self::$paths[''], Path::clean($includePath));
}
}
}

return self::$paths[$prefix];
}

/**
* Method to get the model name
*
Expand Down
50 changes: 0 additions & 50 deletions libraries/src/MVC/Model/LegacyModelLoaderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,6 @@
*/
trait LegacyModelLoaderTrait
{
/**
* Add a directory where \JModelLegacy should search for models. You may
* either pass a string or an array of directories.
*
* @param mixed $path A path or array[sting] of paths to search.
* @param string $prefix A prefix for models.
*
* @return array An array with directory elements. If prefix is equal to '', all directories are returned.
*
* @since 3.0
* @deprecated 5.0 See getInstance
*/
public static function addIncludePath($path = '', $prefix = '')
{
static $paths;

if (!isset($paths))
{
$paths = array();
}

if (!isset($paths[$prefix]))
{
$paths[$prefix] = array();
}

if (!isset($paths['']))
{
$paths[''] = array();
}

if (!empty($path))
{
foreach ((array) $path as $includePath)
{
if (!\in_array($includePath, $paths[$prefix]))
{
array_unshift($paths[$prefix], Path::clean($includePath));
}

if (!\in_array($includePath, $paths['']))
{
array_unshift($paths[''], Path::clean($includePath));
}
}
}

return $paths[$prefix];
}


/**
* Create the filename for a resource
Expand Down