Class CRUDServiceProvider
The CRUDServiceProvider setups and initializes the whole CRUD system.
After adding it to your Silex-setup, it offers access to CRUDlex\CRUDData
instances, one for each defined entity off the CRUD YAML file.
-
CRUDlex\CRUDServiceProvider
implements
Silex\ServiceProviderInterface
Methods summary
protected
string
|
#
formatTime( string $value, string $pattern )
Formats the given time value to a timestring defined by the $pattern
parameter.
Formats the given time value to a timestring defined by the $pattern
parameter.
If the value is false (like null), an empty string is
returned. Else, the value is tried to be parsed as datetime via the
given pattern. If that fails, it is tried to be parsed with the pattern
'Y-m-d H:i:s'. If that fails, the value is returned unchanged. Else, it
is returned formatted with the given pattern. The effect is to shorten
'Y-m-d H:i:s' to 'Y-m-d' for example.
Parameters
- $value
- the value to be formatted
- $pattern
- the pattern with which the value is parsed and formatted
Returns
string the formatted value
|
public
|
#
init( CRUDlex\CRUDDataFactoryInterface $dataFactory, string $crudFile, string $stringsFile, CRUDlex\CRUDFileProcessorInterface $fileProcessor )
Initializes the instance.
Initializes the instance.
Parameters
- $dataFactory
- the factory to create the concrete CRUDData instances
- $crudFile
- the CRUD YAML file to parse
- $stringsFile
- the YAML file containing the displayed strings
- $fileProcessor
- the file processor used for file fields
|
public
|
#
register( Silex\Application $app )
Implements ServiceProviderInterface::register() registering $app['crud'].
$app['crud'] contains an instance of the CRUDServiceProvider afterwards.
Implements ServiceProviderInterface::register() registering $app['crud'].
$app['crud'] contains an instance of the CRUDServiceProvider afterwards.
Parameters
- $app
- the Application instance of the Silex application
|
public
|
#
boot( Silex\Application $app )
Implements ServiceProviderInterface::boot().
Implements ServiceProviderInterface::boot().
Parameters
- $app
- the Application instance of the Silex application
|
public
CRUDlex\CRUDData
|
#
getData( string $name )
Getter for the CRUDlex\CRUDData instances.
Parameters
- $name
- the entity name of the desired CRUDData instance
Returns
|
public
array
|
#
getEntities( )
Getter for all available entity names.
Getter for all available entity names.
Returns
array a list of all available entity names
|
public
string
|
#
formatDate( string $value )
Formats the given value to a date of the format 'Y-m-d'.
Formats the given value to a date of the format 'Y-m-d'.
Parameters
- $value
- the value, might be of the format 'Y-m-d H:i' or 'Y-m-d'
Returns
string the formatted result or an empty string on null value
|
public
string
|
#
formatDateTime( string $value )
Formats the given value to a date of the format 'Y-m-d H:i'.
Formats the given value to a date of the format 'Y-m-d H:i'.
Parameters
- $value
- the value, might be of the format 'Y-m-d H:i'
Returns
string the formatted result or an empty string on null value
|
public
string
|
#
translate( string $key, array $placeholders = array() )
Picks up the string of the given key from the strings and returns the
value. Optionally replaces placeholder from "{0}" to "{n}" with the values given via
the array $placeholders.
Picks up the string of the given key from the strings and returns the
value. Optionally replaces placeholder from "{0}" to "{n}" with the values given via
the array $placeholders.
Parameters
- $key
- the key
- $placeholders
- the optional placeholders
Returns
string the string value or the key in case there was no string found for the key
|
public
string
|
#
basename( string $value )
Calls PHPs
basename and
returns it's result.
Calls PHPs
basename and
returns it's result.
Parameters
- $value
- the value to be handed to basename
Returns
string the result of basename
|
Properties summary
protected
mixed
|
$datas
|
|
protected
mixed
|
$strings
Holds the translation map.
Holds the translation map.
|
|