Class MetadataLoader
Load metadata from JSON file(s).
The Metadata Loader is different than the FileLoader
class it extends mainly because
it tries to find all files matching the "ident" in all search path and merge them together
in an array, to be filled in a Metadata
object.
If ident
is an actual class name, then it will also try to load all the JSON matching
the class' parents and interfaces.
-
Charcoal\Model\Service\MetadataLoader
implements
Psr\Log\LoggerAwareInterface
uses
Psr\Log\LoggerAwareTrait (not available)
Methods summary
public
|
#
__construct( array $data = null )
Return new MetadataLoader object.
Return new MetadataLoader object.
The application's metadata paths, if any, are merged with
the loader's search paths.
Required dependencie
logger
cache
paths
base_path
Parameters
- $data
- The loader's dependencies.
|
public
array
|
#
load( string $ident, Charcoal\Model\MetadataInterface $metadata, array $interfaces = null )
Load the metadata for the given identifier or interfaces.
Load the metadata for the given identifier or interfaces.
Parameters
- $ident
The metadata identifier to load or
to use as the cache key if $interfaces is provided.
- $metadata
- The metadata object to load into.
- $interfaces
- One or more metadata identifiers to load.
Returns
array Returns the cached metadata instance or if it's stale or empty,
loads a fresh copy of the data into $metadata and returns it;
Throws
InvalidArgumentException If the identifier is not a string.
|
public
array
|
#
loadData( string $ident )
Fetch the metadata for the given identifier.
Fetch the metadata for the given identifier.
Parameters
- $ident
- The metadata identifier to load.
Returns
array
Throws
InvalidArgumentException If the identifier is not a string.
|
public
array
|
#
loadDataArray( array $idents )
Fetch the metadata for the given identifiers.
Fetch the metadata for the given identifiers.
Parameters
- $idents
- One or more metadata identifiers to load.
Returns
array
|
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.
|