# 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

Namespace: CRUDlex
Located at CRUDServiceProvider.php

Methods summary
`protected string` | # `formatTime( string $value, string $timezone, 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 $timezone the timezone of the value $pattern the pattern with which the value is parsed and formatted #### Returns string the formatted value
`protected string` | # `readYaml( string $fileName )` Reads and returns the contents of the given file. If it goes wrong, it throws an exception. Reads and returns the contents of the given file. If it goes wrong, it throws an exception. #### Parameters $fileName the file to read #### Returns string the file contents
`protected` | # `initMissingServiceProviders( Silex\Application $app )` Initializes needed but yet missing service providers. Initializes needed but yet missing service providers. #### Parameters $app the application container
`protected array` | # `initLocales( Silex\Application $app )` Initializes the available locales. Initializes the available locales. #### Parameters $app the application container #### Returns array the available locales
`protected` | # `initChildren( )` Initializes the children of the data entries. Initializes the children of the data entries.
`protected array` | # `getLocaleLabels( array $locales, array $crud )` Gets a map with localized entity labels from the CRUD YML. Gets a map with localized entity labels from the CRUD YML. #### Parameters $locales the available locales $crud the CRUD entity map #### Returns array the map with localized entity labels
`protected` | # `configureDefinition( `CRUDlex\CRUDEntityDefinition` $definition, array $crud )` Configures the CRUDEntityDefinition according to the given CRUD entity map. Configures the CRUDEntityDefinition according to the given CRUD entity map. #### Parameters $definition the definition to configure $crud the CRUD entity map
`public` | # `init( `CRUDlex\CRUDDataFactoryInterface` $dataFactory, string $crudFile, `CRUDlex\CRUDFileProcessorInterface` $fileProcessor, boolean $manageI18n, Silex\Application $app )` Initializes the instance. Initializes the instance. #### Parameters $dataFactory the factory to create the concrete CRUDData instances $crudFile the CRUD YAML file to parse $fileProcessor the file processor used for file fields $manageI18n holds whether we manage the i18n $app the application container
`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. Getter for the `CRUDlex\CRUDData` instances. #### Parameters $name the entity name of the desired CRUDData instance #### Returns `CRUDlex\CRUDData` the CRUDData instance or null on invalid name
`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, boolean $isUTC )` 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' $isUTC whether the given value is in UTC #### Returns string the formatted result or an empty string on null value
`public string` | # `formatDateTime( string $value, boolean $isUTC )` 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' $isUTC whether the given value is in UTC #### Returns string the formatted result or an empty string on null value
`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
`public string` | # `getTemplate( Silex\Application $app, string $section, string $action, string $entity )` Determines the Twig template to use for the given parameters depending on the existance of certain keys in the Application $app in this order: Determines the Twig template to use for the given parameters depending on the existance of certain keys in the Application $app in this order: crud.$section.$action.$entity crud.$section.$action crud.$section If nothing exists, this string is returned: "@crud/.twig" #### Parameters $app the Silex application $section the section of the template, either "layout" or "template" $action the current calling action like "create" or "show" $entity the current calling entity #### Returns string the best fitting template
`public boolean` | # `getManageI18n( )` Gets whether CRUDlex manages the i18n system. Gets whether CRUDlex manages the i18n system. #### Returns boolean true if CRUDlex manages the i18n system
`public` | # `setLocale( string $locale )` Sets the locale to be used. Sets the locale to be used. #### Parameters $locale the locale to be used.
`public array` | # `getLocales( )` Gets the available locales. Gets the available locales. #### Returns array the available locales
`public string` | # `getLanguageName( string $language )` Gets a language name in the given language. Gets a language name in the given language. #### Parameters $language the language code of the desired language name #### Returns string the language name in the given language or null if not available
`public string` | # `formatFloat( float $float )` Formats a float to not display in scientific notation. Formats a float to not display in scientific notation. #### Parameters $float the float to format #### Returns string the formated float

Properties summary
`protected` | $datas Holds the `CRUDlex\CRUDData` instances. Holds the `CRUDlex\CRUDData` instances. | # ``
`protected` | $manageI18n Holds whether we manage the i18n. Holds whether we manage the i18n. | # ``