phpBB API Documentation
Class

phpbb\finder

class finder

The finder provides a simple way to locate files in the core and a set of extensions

Methods

__construct(filesystem_interface $filesystem, string $phpbb_root_path = '', service $cache = null, string $php_ext = 'php', string $cache_name = '_ext_finder')

Creates a new finder instance with its dependencies

finder set_extensions(array $extensions, bool $replace_list = true)

Set the array of extensions

finder core_path(string $core_path)

Sets a core path to be searched in addition to extensions

finder suffix(string $suffix)

Sets the suffix all files found in extensions and core must match.

finder extension_suffix(string $extension_suffix)

Sets a suffix all files found in extensions must match

finder core_suffix(string $core_suffix)

Sets a suffix all files found in the core path must match

finder prefix(string $prefix)

Sets the prefix all files found in extensions and core must match

finder extension_prefix(string $extension_prefix)

Sets a prefix all files found in extensions must match

finder core_prefix(string $core_prefix)

Sets a prefix all files found in the core path must match

finder directory(string $directory)

Sets a directory all files found in extensions and core must be contained in

finder extension_directory(string $extension_directory)

Sets a directory all files found in extensions must be contained in

finder core_directory(string $core_directory)

Sets a directory all files found in the core path must be contained in

array get_classes(bool $cache = true)

Finds classes matching the configured options if they follow phpBB naming rules.

array get_classes_from_files(array $files)

Get class names from a list of files

array get_directories(bool $cache = true, bool $extension_keys = false)

Finds all directories matching the configured options

array get_files(bool $cache = true)

Finds all files matching the configured options.

array find(bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options

array find_from_extension(string $extension_name, string $extension_path, bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options for one specific extension

array find_from_paths(array $extensions, bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options from an array of paths

Details

at line 58
public __construct(filesystem_interface $filesystem, string $phpbb_root_path = '', service $cache = null, string $php_ext = 'php', string $cache_name = '_ext_finder')

Creates a new finder instance with its dependencies

Parameters

filesystem_interface $filesystem Filesystem instance
string $phpbb_root_path Path to the phpbb root directory
service $cache A cache instance or null
string $php_ext php file extension
string $cache_name The name of the cache variable, defaults to extfinder

at line 87
public finder set_extensions(array $extensions, bool $replace_list = true)

Set the array of extensions

Parameters

array $extensions A list of extensions that should be searched aswell
bool $replace_list Should the list be emptied before adding the extensions

Return Value

finder This object for chaining calls

at line 107
public finder core_path(string $core_path)

Sets a core path to be searched in addition to extensions

Parameters

string $core_path The path relative to phpbbrootpath

Return Value

finder This object for chaining calls

at line 123
public finder suffix(string $suffix)

Sets the suffix all files found in extensions and core must match.

There is no default file extension, so to find PHP files only, you will have to specify .php as a suffix. However when using get_classes, the .php file extension is automatically added to suffixes.

Parameters

string $suffix A filename suffix

Return Value

finder This object for chaining calls

at line 140
public finder extension_suffix(string $extension_suffix)

Sets a suffix all files found in extensions must match

There is no default file extension, so to find PHP files only, you will have to specify .php as a suffix. However when using get_classes, the .php file extension is automatically added to suffixes.

Parameters

string $extension_suffix A filename suffix

Return Value

finder This object for chaining calls

at line 156
public finder core_suffix(string $core_suffix)

Sets a suffix all files found in the core path must match

There is no default file extension, so to find PHP files only, you will have to specify .php as a suffix. However when using get_classes, the .php file extension is automatically added to suffixes.

Parameters

string $core_suffix A filename suffix

Return Value

finder This object for chaining calls

at line 168
public finder prefix(string $prefix)

Sets the prefix all files found in extensions and core must match

Parameters

string $prefix A filename prefix

Return Value

finder This object for chaining calls

at line 181
public finder extension_prefix(string $extension_prefix)

Sets a prefix all files found in extensions must match

Parameters

string $extension_prefix A filename prefix

Return Value

finder This object for chaining calls

at line 193
public finder core_prefix(string $core_prefix)

Sets a prefix all files found in the core path must match

Parameters

string $core_prefix A filename prefix

Return Value

finder This object for chaining calls

at line 208
public finder directory(string $directory)

Sets a directory all files found in extensions and core must be contained in

Automatically sets the core_directory if its value does not differ from the current directory.

Parameters

string $directory

Return Value

finder This object for chaining calls

at line 221
public finder extension_directory(string $extension_directory)

Sets a directory all files found in extensions must be contained in

Parameters

string $extension_directory

Return Value

finder This object for chaining calls

at line 233
public finder core_directory(string $core_directory)

Sets a directory all files found in the core path must be contained in

Parameters

string $core_directory

Return Value

finder This object for chaining calls

at line 269
public array get_classes(bool $cache = true)

Finds classes matching the configured options if they follow phpBB naming rules.

The php file extension is automatically added to suffixes.

Note: If a file is matched but contains a class name not following the phpBB naming rules an incorrect class name will be returned.

Parameters

bool $cache Whether the result should be cached

Return Value

array An array of found class names

at line 285
public array get_classes_from_files(array $files)

Get class names from a list of files

Parameters

array $files Array of files (from find())

Return Value

array Array of class names

at line 312
public array get_directories(bool $cache = true, bool $extension_keys = false)

Finds all directories matching the configured options

Parameters

bool $cache Whether the result should be cached
bool $extension_keys Whether the result should have extension name as array key

Return Value

array An array of paths to found directories

at line 323
public array get_files(bool $cache = true)

Finds all files matching the configured options.

Parameters

bool $cache Whether the result should be cached

Return Value

array An array of paths to found files

at line 366
public array find(bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options

Parameters

bool $cache Whether the result should be cached
bool $is_dir Directories will be returned when true, only files otherwise

Return Value

array An array of paths to found items

at line 396
public array find_from_extension(string $extension_name, string $extension_path, bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options for one specific extension

Parameters

string $extension_name Name of the extension
string $extension_path Relative path to the extension root directory
bool $cache Whether the result should be cached
bool $is_dir Directories will be returned when true, only files otherwise

Return Value

array An array of paths to found items

at line 423
public array find_from_paths(array $extensions, bool $cache = true, bool $is_dir = false)

Finds all file system entries matching the configured options from an array of paths

Parameters

array $extensions Array of extensions (name => full relative path)
bool $cache Whether the result should be cached
bool $is_dir Directories will be returned when true, only files otherwise

Return Value

array An array of paths to found items