PHP Class CRUDlex\ServiceProvider

After adding it to your Silex-setup, it offers access to {@see \AbstractData} instances, one for each defined entity off the CRUD YAML file.
Inheritance: implements Pimple\ServiceProviderInterface
Afficher le fichier Open project: philiplb/crudlex Class Usage Examples

Protected Properties

Свойство Type Description
$datas Holds the {@see AbstractData} instances.
$manageI18n Holds whether we manage the i18n.

Méthodes publiques

Méthode Description
getData ( string $name ) : AbstractData Getter for the {@see AbstractData} instances.
getEntities ( ) : string[] Getter for all available entity names.
getLocales ( ) : array Gets the available locales.
getTemplate ( Pimple\Container $app, string $section, string $action, string $entity ) : string Determines the Twig template to use for the given parameters depending on the existance of certain keys in the Container $app in this order:
init ( crudlex\DataFactoryInterface $dataFactory, string $crudFile, crudlex\FileProcessorInterface $fileProcessor, boolean $manageI18n, Pimple\Container $app ) Initializes the instance.
isManagingI18n ( ) : boolean Gets whether CRUDlex manages the i18n system.
register ( Pimple\Container $app ) Implements ServiceProviderInterface::register() registering $app['crud'].
setLocale ( string $locale ) Sets the locale to be used.

Méthodes protégées

Méthode Description
configureDefinition ( EntityDefinition $definition, array $crud ) Configures the EntityDefinition according to the given CRUD entity map.
createDefinition ( Pimple\Container $app, array $locales, array $crud, string $name ) : EntityDefinition Creates and setups an EntityDefinition instance.
getLocaleLabels ( array $locales, array $crud ) : array Gets a map with localized entity labels from the CRUD YML.
initChildren ( ) Initializes the children of the data entries.
initLocales ( Pimple\Container $app ) : array Initializes the available locales.
initMissingServiceProviders ( Pimple\Container $app ) Initializes needed but yet missing service providers.
readYaml ( string $fileName ) : array Reads and returns the contents of the given Yaml file. If it goes wrong, it throws an exception.
validateEntityDefinition ( Pimple\Container $app, array $entityDefinition ) Validates the parsed entity definition.

Method Details

configureDefinition() protected méthode

Configures the EntityDefinition according to the given CRUD entity map.
protected configureDefinition ( EntityDefinition $definition, array $crud )
$definition EntityDefinition the definition to configure
$crud array the CRUD entity map

createDefinition() protected méthode

Creates and setups an EntityDefinition instance.
protected createDefinition ( Pimple\Container $app, array $locales, array $crud, string $name ) : EntityDefinition
$app Pimple\Container the application container
$locales array the available locales
$crud array the parsed YAML of a CRUD entity
$name string the name of the entity
Résultat EntityDefinition the EntityDefinition good to go

getData() public méthode

Getter for the {@see AbstractData} instances.
public getData ( string $name ) : AbstractData
$name string the entity name of the desired Data instance
Résultat AbstractData the AbstractData instance or null on invalid name

getEntities() public méthode

Getter for all available entity names.
public getEntities ( ) : string[]
Résultat string[] a list of all available entity names

getLocaleLabels() protected méthode

Gets a map with localized entity labels from the CRUD YML.
protected getLocaleLabels ( array $locales, array $crud ) : array
$locales array the available locales
$crud array the CRUD entity map
Résultat array the map with localized entity labels

getLocales() public méthode

Gets the available locales.
public getLocales ( ) : array
Résultat array the available locales

getTemplate() public méthode

crud.$section.$action.$entity crud.$section.$action crud.$section If nothing exists, this string is returned: "@crud/.twig"
public getTemplate ( Pimple\Container $app, string $section, string $action, string $entity ) : string
$app Pimple\Container the Silex application
$section string the section of the template, either "layout" or "template"
$action string the current calling action like "create" or "show"
$entity string the current calling entity
Résultat string the best fitting template

init() public méthode

Initializes the instance.
public init ( crudlex\DataFactoryInterface $dataFactory, string $crudFile, crudlex\FileProcessorInterface $fileProcessor, boolean $manageI18n, Pimple\Container $app )
$dataFactory crudlex\DataFactoryInterface the factory to create the concrete AbstractData instances
$crudFile string the CRUD YAML file to parse
$fileProcessor crudlex\FileProcessorInterface the file processor used for file fields
$manageI18n boolean holds whether we manage the i18n
$app Pimple\Container the application container

initChildren() protected méthode

Initializes the children of the data entries.
protected initChildren ( )

initLocales() protected méthode

Initializes the available locales.
protected initLocales ( Pimple\Container $app ) : array
$app Pimple\Container the application container
Résultat array the available locales

initMissingServiceProviders() protected méthode

Initializes needed but yet missing service providers.
protected initMissingServiceProviders ( Pimple\Container $app )
$app Pimple\Container the application container

isManagingI18n() public méthode

Gets whether CRUDlex manages the i18n system.
public isManagingI18n ( ) : boolean
Résultat boolean true if CRUDlex manages the i18n system

readYaml() protected méthode

Reads and returns the contents of the given Yaml file. If it goes wrong, it throws an exception.
protected readYaml ( string $fileName ) : array
$fileName string the file to read
Résultat array the file contents

register() public méthode

$app['crud'] contains an instance of the ServiceProvider afterwards.
public register ( Pimple\Container $app )
$app Pimple\Container the Container instance of the Silex application

setLocale() public méthode

Sets the locale to be used.
public setLocale ( string $locale )
$locale string the locale to be used.

validateEntityDefinition() protected méthode

Validates the parsed entity definition.
protected validateEntityDefinition ( Pimple\Container $app, array $entityDefinition )
$app Pimple\Container the application container
$entityDefinition array the entity definition to validate

Property Details

$datas protected_oe property

Holds the {@see AbstractData} instances.
protected $datas

$manageI18n protected_oe property

Holds whether we manage the i18n.
protected $manageI18n