PHP Класс 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.
Наследование: implements Pimple\ServiceProviderInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$datas Holds the {@see AbstractData} instances.
$manageI18n Holds whether we manage the i18n.

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Описание методов

configureDefinition() защищенный Метод

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() защищенный Метод

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
Результат EntityDefinition the EntityDefinition good to go

getData() публичный Метод

Getter for the {@see AbstractData} instances.
public getData ( string $name ) : AbstractData
$name string the entity name of the desired Data instance
Результат AbstractData the AbstractData instance or null on invalid name

getEntities() публичный Метод

Getter for all available entity names.
public getEntities ( ) : string[]
Результат string[] a list of all available entity names

getLocaleLabels() защищенный Метод

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
Результат array the map with localized entity labels

getLocales() публичный Метод

Gets the available locales.
public getLocales ( ) : array
Результат array the available locales

getTemplate() публичный Метод

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
Результат string the best fitting template

init() публичный Метод

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() защищенный Метод

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

initLocales() защищенный Метод

Initializes the available locales.
protected initLocales ( Pimple\Container $app ) : array
$app Pimple\Container the application container
Результат array the available locales

initMissingServiceProviders() защищенный Метод

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

isManagingI18n() публичный Метод

Gets whether CRUDlex manages the i18n system.
public isManagingI18n ( ) : boolean
Результат boolean true if CRUDlex manages the i18n system

readYaml() защищенный Метод

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
Результат array the file contents

register() публичный Метод

$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() публичный Метод

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

validateEntityDefinition() защищенный Метод

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

Описание свойств

$datas защищенное свойство

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

$manageI18n защищенное свойство

Holds whether we manage the i18n.
protected $manageI18n