Back to BaseModel class

Method addIncludePath

public static array
addIncludePath
(mixed $path = '', mixed $prefix = '')
Add a directory where \JModelLegacy should search for models. You may either pass a string or an array of directories.
Parameters
  • mixed $path A path or array[sting] of paths to search.
  • string $prefix A prefix for models.
Returns
  • array An array with directory elements. If prefix is equal to '', all directories are returned.
Since
  • 3.0
Deprecated
  • 5.0
Class: BaseModel
Project: Joomla

Method addIncludePath - Source code

/**
 * 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 LegacyModelLoaderTrait\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];
}