PHP Class FluentExtension

Author: Damian Mooyman ([email protected])
Inheritance: extends DataExtension
Afficher le fichier Open project: tractorcow/silverstripe-fluent Class Usage Examples

Protected Properties

Свойство Type Description
$_enable_write_augmentation
$disable_fluent_fields boolean Hook allowing temporary disabling of extra fluent fields
$translated_fields_for_cache array Cache for list of translated fields for all inspected classes

Méthodes publiques

Méthode Description
BaseURLForLocale ( string $locale = null ) : string Determine the baseurl within a specified $locale.
CurrentLocale ( ) : string Current locale code
LocaleInformation ( string $locale = null ) : ArrayData Retrieves information about this object in the specified locale
LocaleLink ( string $locale ) : string Determine the link to this object given the specified $locale.
Locales ( ) : ArrayList Templatable list of all locales
augmentDataQueryCreation ( SQLQuery $query, DataQuery $dataQuery ) Amend freshly created DataQuery objects with the current locale and frontend status
augmentSQL ( SQLQuery &$query, DataQuery &$dataQuery = null )
augmentWrite ( &$manipulation )
base_indexes ( $class )
generate_extra_config ( string $class ) Generates the extra DB fields for a class (not including subclasses)
get_extra_config ( $class, $extension, $args )
isFieldNullable ( string $field ) : boolean Can this field be left empty?
onBeforeWrite ( )
set_enable_write_augmentation ( $enabled ) * Enable or disable write augmentations. Useful for setting up test cases with specific hard coded values.
translated_fields_for ( $class ) : array Determines the fields to translate on the given class
updateCMSFields ( FieldList $fields )

Méthodes protégées

Méthode Description
addLocaleIndicatorMessage ( FieldList $fields ) Adds a UI message to indicate whether you're editing in the default locale or not
detectFilterColumn ( string $condition, array $includedTables ) : array Determines the table/column identifier that first appears in the $condition, and returns the localised version of that column.
determine_index_type ( type $spec ) : string Given an index spec determines the index type
explode_column_string ( string $spec ) : array Splits a spec string safely, considering quoted columns, whitespace, and cleaning brackets
getTranslatedTables ( ) : array Get all database tables in the class ancestry and their respective translatable fields
implode_column_list ( array $columns ) : string Builds a properly quoted column list from an array
localiseFilterCondition ( string $condition, array $includedTables, string $locale ) : string Replaces all columns in the given condition with any localised
localiseSelect ( string $class, string $select, string $fallback ) : string Generates a select fragment based on a field with a fallback
parse_index_spec ( $name, string | array $spec ) : array Converts an array or string index spec into a universally useful array
quote_column_spec_string ( string $spec ) : string Given an index specification in the form of a string ensure that each column name is property quoted, stripping brackets and modifiers.
without_fluent_fields ( callback $callback ) : mixed Executes a callback with extra fluent fields disabled

Method Details

BaseURLForLocale() public méthode

Determine the baseurl within a specified $locale.
public BaseURLForLocale ( string $locale = null ) : string
$locale string Locale, or null to use current locale
Résultat string

CurrentLocale() public méthode

Current locale code
public CurrentLocale ( ) : string
Résultat string Locale code

LocaleInformation() public méthode

Retrieves information about this object in the specified locale
public LocaleInformation ( string $locale = null ) : ArrayData
$locale string The locale information to request, or null to use the default locale
Résultat ArrayData Mapped list of locale properties

Locales() public méthode

Templatable list of all locales
public Locales ( ) : ArrayList
Résultat ArrayList

addLocaleIndicatorMessage() protected méthode

Adds a UI message to indicate whether you're editing in the default locale or not
protected addLocaleIndicatorMessage ( FieldList $fields )
$fields FieldList

augmentDataQueryCreation() public méthode

Amend freshly created DataQuery objects with the current locale and frontend status
public augmentDataQueryCreation ( SQLQuery $query, DataQuery $dataQuery )
$query SQLQuery
$dataQuery DataQuery

augmentSQL() public méthode

public augmentSQL ( SQLQuery &$query, DataQuery &$dataQuery = null )
$query SQLQuery
$dataQuery DataQuery

augmentWrite() public méthode

public augmentWrite ( &$manipulation )

base_indexes() public static méthode

public static base_indexes ( $class )

detectFilterColumn() protected méthode

Determines the table/column identifier that first appears in the $condition, and returns the localised version of that column.
protected detectFilterColumn ( string $condition, array $includedTables ) : array
$condition string Condition SQL string
$includedTables array
Résultat array Array with items [$table, $column], or null if not found

determine_index_type() protected static méthode

Given an index spec determines the index type
protected static determine_index_type ( type $spec ) : string
$spec type
Résultat string

explode_column_string() protected static méthode

Splits a spec string safely, considering quoted columns, whitespace, and cleaning brackets
protected static explode_column_string ( string $spec ) : array
$spec string The input index specification
Résultat array List of columns in the spec

generate_extra_config() public static méthode

Generates the extra DB fields for a class (not including subclasses)
public static generate_extra_config ( string $class )
$class string

getTranslatedTables() protected méthode

Get all database tables in the class ancestry and their respective translatable fields
protected getTranslatedTables ( ) : array
Résultat array

get_extra_config() public static méthode

public static get_extra_config ( $class, $extension, $args )

implode_column_list() protected static méthode

Builds a properly quoted column list from an array
protected static implode_column_list ( array $columns ) : string
$columns array List of columns to implode
Résultat string A properly quoted list of column names

isFieldNullable() public méthode

Can this field be left empty?
public isFieldNullable ( string $field ) : boolean
$field string
Résultat boolean False if the field inherits, true if it is nullable

localiseFilterCondition() protected méthode

Replaces all columns in the given condition with any localised
protected localiseFilterCondition ( string $condition, array $includedTables, string $locale ) : string
$condition string Condition SQL string
$includedTables array
$locale string Locale to localise to
Résultat string $condition parameter with column names replaced

localiseSelect() protected méthode

Generates a select fragment based on a field with a fallback
protected localiseSelect ( string $class, string $select, string $fallback ) : string
$class string Table/Class name
$select string Column to select from
$fallback string Column to fallback to if $select is empty
Résultat string Select fragment

onBeforeWrite() public méthode

public onBeforeWrite ( )

parse_index_spec() protected static méthode

Converts an array or string index spec into a universally useful array
protected static parse_index_spec ( $name, string | array $spec ) : array
$spec string | array
Résultat array The resulting spec array with the required fields name, type, and value

quote_column_spec_string() protected static méthode

This index may also be in the form of a "CREATE INDEX..." sql fragment
protected static quote_column_spec_string ( string $spec ) : string
$spec string The input specification or query. E.g. 'unique (Column1, Column2)'
Résultat string The properly quoted column list. E.g. '"Column1", "Column2"'

set_enable_write_augmentation() public static méthode

* Enable or disable write augmentations. Useful for setting up test cases with specific hard coded values.
public static set_enable_write_augmentation ( $enabled )
$enabled

translated_fields_for() public static méthode

Determines the fields to translate on the given class
public static translated_fields_for ( $class ) : array
Résultat array List of field names and data types

updateCMSFields() public méthode

public updateCMSFields ( FieldList $fields )
$fields FieldList

without_fluent_fields() protected static méthode

Executes a callback with extra fluent fields disabled
protected static without_fluent_fields ( callback $callback ) : mixed
$callback callback
Résultat mixed

Property Details

$_enable_write_augmentation protected_oe static_oe property

protected static $_enable_write_augmentation

$disable_fluent_fields protected_oe static_oe property

Hook allowing temporary disabling of extra fluent fields
protected static bool $disable_fluent_fields
Résultat boolean

$translated_fields_for_cache protected_oe static_oe property

Cache for list of translated fields for all inspected classes
protected static array $translated_fields_for_cache
Résultat array