Class ModelLoader
Load a single model from its source, of from cache.
Use the magic methods to load automatically from __call and __get; this allows
for easy integration in templating engines like Mustache.
This object is immutable.
-
Charcoal\Model\Service\ModelLoader
implements
ArrayAccess
Methods summary
public
|
#
__construct( array $data )
Construct a Model Loader with the dependencies
Construct a Model Loader with the dependencies
Required Dependencies
Optional Dependencies
Parameters
- $data
- Loader dependencies.
|
public
Charcoal\Model\ModelInterface
|
#
__call( string|integer $ident, mixed $args = null )
Retrieve an object by its key.
Retrieve an object by its key.
Parameters
- $ident
- The object identifier to load.
- $args
- Unused; Method arguments.
Returns
|
public
Charcoal\Model\ModelInterface
|
#
__get( string|integer $ident )
Retrieve an object by its key.
Retrieve an object by its key.
Parameters
- $ident
- The object identifier to load.
Returns
|
public
boolean
|
#
__isset( string $ident )
Determine if an object exists by its key.
Determine if an object exists by its key.
Parameters
- $ident
- The object identifier to lookup.
Returns
boolean
|
public
|
#
__unset( string|integer $ident )
Remove an object by its key.
Remove an object by its key.
Parameters
- $ident
- The object identifier to remove.
Throws
LogicException This method should never be called.
|
public
boolean
|
#
offsetExists( string $ident )
Determine if an object exists by its key.
Determine if an object exists by its key.
Parameters
- $ident
- The object identifier to lookup.
Returns
boolean
See
ArrayAccess::offsetExists
Implementation of
ArrayAccess::offsetExists()
|
public
Charcoal\Model\ModelInterface
|
#
offsetGet( string|integer $ident )
Retrieve an object by its key.
Retrieve an object by its key.
Parameters
- $ident
- The object identifier to load.
Returns
See
ArrayAccess::offsetGet
Implementation of
ArrayAccess::offsetGet()
|
public
|
#
offsetSet( string|integer $ident, mixed $obj )
Add an object.
Parameters
- $ident
- The $object identifier.
- $obj
- The object to add.
Throws
LogicException This method should never be called.
See
ArrayAccess::offsetSet
Implementation of
ArrayAccess::offsetSet()
|
public
|
#
offsetUnset( string|integer $ident )
Remove an object by its key.
Remove an object by its key.
Parameters
- $ident
- The object identifier to remove.
Throws
LogicException This method should never be called.
See
ArrayAccess::offsetUnset()
Implementation of
ArrayAccess::offsetUnset()
|
public
Charcoal\Model\ModelInterface
|
#
load( string|integer $ident, boolean $useCache = true, boolean $reloadObj = false )
Retrieve an object, by its key, from its source or from the cache.
Retrieve an object, by its key, from its source or from the cache.
When the cache is enabled, only the object's data is stored. This prevents issues
when unserializing a class that might have dependencies.
Parameters
- $ident
- The object identifier to load.
- $useCache
- If FALSE, ignore the cached object. Defaults to TRUE.
- $reloadObj
- If TRUE, refresh the cached object. Defaults to FALSE.
Returns
|