PHP Class FluentExtension

Author: Damian Mooyman ([email protected])
Inheritance: extends DataExtension
显示文件 Open project: tractorcow/silverstripe-fluent Class Usage Examples

Protected Properties

Property 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

Public Methods

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

Protected Methods

Method 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 method

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

CurrentLocale() public method

Current locale code
public CurrentLocale ( ) : string
return string Locale code

LocaleInformation() public method

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
return ArrayData Mapped list of locale properties

Locales() public method

Templatable list of all locales
public Locales ( ) : ArrayList
return ArrayList

addLocaleIndicatorMessage() protected method

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

augmentDataQueryCreation() public method

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

augmentSQL() public method

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

augmentWrite() public method

public augmentWrite ( &$manipulation )

base_indexes() public static method

public static base_indexes ( $class )

detectFilterColumn() protected method

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
return array Array with items [$table, $column], or null if not found

determine_index_type() protected static method

Given an index spec determines the index type
protected static determine_index_type ( type $spec ) : string
$spec type
return string

explode_column_string() protected static method

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
return array List of columns in the spec

generate_extra_config() public static method

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

getTranslatedTables() protected method

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

get_extra_config() public static method

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

implode_column_list() protected static method

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

isFieldNullable() public method

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

localiseFilterCondition() protected method

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
return string $condition parameter with column names replaced

localiseSelect() protected method

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
return string Select fragment

onBeforeWrite() public method

public onBeforeWrite ( )

parse_index_spec() protected static method

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
return array The resulting spec array with the required fields name, type, and value

quote_column_spec_string() protected static method

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)'
return string The properly quoted column list. E.g. '"Column1", "Column2"'

set_enable_write_augmentation() public static method

* 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 method

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

updateCMSFields() public method

public updateCMSFields ( FieldList $fields )
$fields FieldList

without_fluent_fields() protected static method

Executes a callback with extra fluent fields disabled
protected static without_fluent_fields ( callback $callback ) : mixed
$callback callback
return 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
return 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
return array