Overview

Namespaces

  • CRUDlex

Classes

  • CRUDControllerProvider
  • CRUDData
  • CRUDEntity
  • CRUDEntityDefinition
  • CRUDMySQLData
  • CRUDMySQLDataFactory
  • CRUDServiceProvider
  • CRUDSimpleFilesystemFileProcessor

Interfaces

  • CRUDDataFactoryInterface
  • CRUDFileProcessorInterface
  • Overview
  • Namespace
  • Class

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 $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
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
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 )

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
# 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 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.

#
CRUDlex API API documentation generated by ApiGen