The Finder class allows for searching through a search path for a given file, as well as loading a given file.

package Fuel
subpackage Core

 Methods

Takes in an array of paths, preps them and gets the party started.

__construct(array $paths) 

Parameters

$paths

array

The paths to initialize with

_init()

_init() 

Adds a path (or paths) to the search path at a given position.

add_path(string | array $paths, int $pos) : \Fuel\Core\Finder

Possible positions: (null): Append to the end of the search path (-1): Prepend to the start of the search path (index): The path will get inserted AFTER the given index

fluent This method is part of a fluent interface and will return the same instance

Parameters

$paths

stringarray

The path to add

$pos

int

The position to add the path

Exceptions

\OutOfBoundsException

Returns

Clears the flash paths.

clear_flash() : \Fuel\Core\Finder

fluent This method is part of a fluent interface and will return the same instance

Returns

Adds multiple flash paths.

flash(array $paths) : \Fuel\Core\Finder

fluent This method is part of a fluent interface and will return the same instance

Parameters

$paths

array

The paths to add

Returns

Forges new Finders.

forge(array $paths) : \Fuel\Core\Finder

Parameters

$paths

array

The paths to initialize with

Returns

Gets a singleton instance of Finder

instance() : \Fuel\Core\Finder

Gets a list of all the files in a given directory inside all of the loaded search paths (e.g.

list_files(string $directory, string $filter) : array

the cascading file system). This is useful for things like finding all the config files in all the search paths.

Parameters

$directory

string

The directory to look in

$filter

string

The file filter

Returns

arraythe array of files

Locates a given file in the search paths.

locate(string $dir, string $file, string $ext, bool $multiple, bool $cache) : mixed

Parameters

$dir

string

Directory to look in

$file

string

File to find

$ext

string

File extension

$multiple

bool

Whether to find multiple files

$cache

bool

Whether to cache this path or not

Returns

mixedPath, or paths, or false

Returns the current search paths.

paths() : array

..including flash paths.

Returns

arraySearch paths

Prepares a path for usage.

prep_path(string $path) : string

It ensures that the path has a trailing Directory Separator.

Parameters

$path

string

The path to prepare

Returns

string

Prepares an array of paths.

prep_paths(array $paths) : array

Parameters

$paths

array

The paths to prepare

Returns

array

Reads in the cached paths with the given cache id.

read_cache(string $cache_id) : void

Parameters

$cache_id

string

Cache id to read

Removes a path from the search path.

remove_path(string $path) : \Fuel\Core\Finder

fluent This method is part of a fluent interface and will return the same instance

Parameters

$path

string

Path to remove

Returns

Writes out the cached paths if they need to be.

write_cache(string $cache_id) : void

Parameters

$cache_id

string

Cache id to read

Loads in the given cache_id from the cache if it exists.

add_to_cache(string $cache_id, $path) : string | bool

Parameters

$cache_id

string

Cache id to load

$path

Returns

stringboolPath or false if not found

This method does basic filesystem caching.

cache(string $name, array $data, int $lifetime) : bool | null

It is used for things like path caching.

This method is from KohanaPHP's Kohana class.

Parameters

$name

string

the cache name

$data

array

the data to cache (if non given it returns)

$lifetime

int

the number of seconds for the cache too live

Returns

boolnull

Loads in the given cache_id from the cache if it exists.

from_cache(string $cache_id) : string | bool

Parameters

$cache_id

string

Cache id to load

Returns

stringboolPath or false if not found

 Properties

 

<p>path to the cache file location</p>

$cache_dir : string

 

<p>the amount of time to cache in seconds</p>

$cache_lifetime : int

 

<p>Whether the path cache is valid or not</p>

$cache_valid : bool

 

<p>Cached lookup paths</p>

$cached_paths : array

 

<p>Search paths that only last for one lookup</p>

$flash_paths : array

 

<p>Singleton master instance</p>

$instance : \Fuel\Core\Finder

 

<p>Holds all of the search paths</p>

$paths : array