WP_CLI

Autoloader::add_namespacepublicWP-CLI 1.0

Add a specific namespace structure with our custom autoloader.

Метод класса: Autoloader{}

Хуков нет.

Возвращает

self.

Использование

$Autoloader = new Autoloader();
$Autoloader->add_namespace( $root, $base_dir, $prefix, $suffix, $lowercase, $underscores );
$root(строка) (обязательный)
Root namespace name.
$base_dir(строка) (обязательный)
Directory containing the class files.
$prefix(строка)
Prefix to be added before the class.
По умолчанию: ''
$suffix(строка)
Suffix to be added after the class.
По умолчанию: '.php'
$lowercase(true|false)
Whether the class should be changed to lowercase.
По умолчанию: false
$underscores(true|false)
Whether the underscores should be changed to hyphens.
По умолчанию: false

Код Autoloader::add_namespace() WP-CLI 2.13.0-alpha

public function add_namespace(
	$root,
	$base_dir,
	$prefix = '',
	$suffix = '.php',
	$lowercase = false,
	$underscores = false
) {
	$this->namespaces[] = [
		'root'        => $this->normalize_root( (string) $root ),
		'base_dir'    => $this->add_trailing_slash( (string) $base_dir ),
		'prefix'      => (string) $prefix,
		'suffix'      => (string) $suffix,
		'lowercase'   => (bool) $lowercase,
		'underscores' => (bool) $underscores,
	];

	return $this;
}