Overview

Namespaces

  • Charcoal
    • Loader
    • Model
      • Service
      • ServiceProvider
    • Source
      • Database
    • Validator

Classes

  • CollectionLoader
  • FileLoader
  • Overview
  • Namespace
  • Class

Class FileLoader

Base File Loader

Charcoal\Loader\FileLoader implements Psr\Log\LoggerAwareInterface uses Psr\Log\LoggerAwareTrait (not available)
Namespace: Charcoal\Loader
Located at Charcoal/Loader/FileLoader.php
Methods summary
public
# __construct( array $data = null )

Return new FileLoader object.

Return new FileLoader object.

Parameters

$data
The loader's dependencies.
public string
# ident( )

Retrieve the loader's identifier.

Retrieve the loader's identifier.

Returns

string
public Charcoal\Loader\FileLoader
# setIdent( mixed $ident )

Set the loader's identifier.

Set the loader's identifier.

Parameters

$ident
A subset of language identifiers.

Returns

Charcoal\Loader\FileLoader

Throws

InvalidArgumentException
If the ident is invalid.
public string
# basePath( )

Retrieve the base path for relative search paths.

Retrieve the base path for relative search paths.

Returns

string
public Charcoal\Loader\FileLoader
# setBasePath( string $basePath )

Assign a base path for relative search paths.

Assign a base path for relative search paths.

Parameters

$basePath
The base path to use.

Returns

Charcoal\Loader\FileLoader

Throws

InvalidArgumentException
If the base path parameter is not a string.
public string
# load( string|null $ident = null )

Returns the content of the first file found in search path.

Returns the content of the first file found in search path.

Parameters

$ident
Optional. A file to search for.

Returns

string
The file's content or an empty string.
protected string|null
# loadFirstFromSearchPath( string $filename )

Load the first match from search paths.

Load the first match from search paths.

Parameters

$filename
A file to search for.

Returns

string|null
The matched file's content or an empty string.
protected string
# firstMatchingFilename( string $filename )

Retrieve the first match from search paths.

Retrieve the first match from search paths.

Parameters

$filename
A file to search for.

Returns

string
The full path to the matched file.
protected array
# allMatchingFilenames( string $filename )

Retrieve all matches from search paths.

Retrieve all matches from search paths.

Parameters

$filename
A file to search for.

Returns

array
An array of matches.
protected array|null
# loadJsonFile( mixed $filename )

Load the contents of a JSON file.

Load the contents of a JSON file.

Parameters

$filename
The file path to retrieve.

Returns

array|null

Throws

InvalidArgumentException
If a JSON decoding error occurs.
public string[]
# paths( )

Retrieve the searchable paths.

Retrieve the searchable paths.

Returns

string[]
public Charcoal\Loader\FileLoader
# setPaths( array $paths )

Assign a list of paths.

Assign a list of paths.

Parameters

$paths
The list of paths to add.

Returns

Charcoal\Loader\FileLoader
public Charcoal\Loader\FileLoader
# addPaths( array $paths )

Append a list of paths.

Append a list of paths.

Parameters

$paths
The list of paths to add.

Returns

Charcoal\Loader\FileLoader
public Charcoal\Loader\FileLoader
# addPath( string $path )

Append a path.

Append a path.

Parameters

$path
A file or directory path.

Returns

Charcoal\Loader\FileLoader

Throws

InvalidArgumentException
If the path does not exist or is invalid.
public Charcoal\Loader\FileLoader
# prependPath( string $path )

Prepend a path.

Prepend a path.

Parameters

$path
A file or directory path.

Returns

Charcoal\Loader\FileLoader
public string
# resolvePath( string $path )

Parse a relative path using the base path if needed.

Parse a relative path using the base path if needed.

Parameters

$path
The path to resolve.

Returns

string

Throws

InvalidArgumentException
If the path is invalid.
public boolean
# validatePath( string $path )

Validate a resolved path.

Validate a resolved path.

Parameters

$path
The path to validate.

Returns

boolean
Returns TRUE if the path is valid otherwise FALSE.
Properties summary
protected string $ident

The loader's identifier (for caching found paths).

The loader's identifier (for caching found paths).

#
protected string[] $paths

The paths to search in.

The paths to search in.

# []
API documentation generated by ApiGen