TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
CategoryRegistry Class Reference
Inheritance diagram for CategoryRegistry:
SingletonInterface

Public Member Functions

 __construct ()
 
 add ($extensionKey, $tableName, $fieldName= 'categories', array $options=[], $override=false)
 
 getExtensionKeys ()
 
 getCategorizedTables ()
 
 getCategoryFieldsForTable (array &$configuration)
 
 isRegistered ($tableName, $fieldName= 'categories')
 
 getDatabaseTableDefinitions ()
 
 getDatabaseTableDefinition ($extensionKey)
 
 applyTcaForPreRegisteredTables ()
 
 addCategoryDatabaseSchemaToTablesDefinition (array $sqlString)
 
 addExtensionCategoryDatabaseSchemaToTablesDefinition (array $sqlString, $extensionKey)
 

Static Public Member Functions

static getInstance ()
 
static getTcaFieldConfiguration ($tableName, $fieldName= 'categories', array $fieldConfigurationOverride=[])
 

Protected Member Functions

 applyTcaForTableAndField ($tableName, $fieldName)
 
 registerDefaultCategorizedTables ()
 
 addToAllTCAtypes ($tableName, $fieldName, array $options)
 
 addCategoryTab ($tableName, $fieldName)
 
 addTcaColumn ($tableName, $fieldName, array $options)
 
 getLanguageService ()
 
 remove ($tableName, $fieldName)
 

Protected Attributes

 $registry = []
 
 $extensions = []
 
 $addedCategoryTabs = []
 
 $template = ''
 

Detailed Description

Class to register category configurations.

Definition at line 26 of file CategoryRegistry.php.

Constructor & Destructor Documentation

__construct ( )

Creates this object.

Definition at line 61 of file CategoryRegistry.php.

Member Function Documentation

add (   $extensionKey,
  $tableName,
  $fieldName = 'categories',
array  $options = [],
  $override = false 
)

Adds a new category configuration to this registry. TCA changes are directly applied

Parameters
string$extensionKeyExtension key to be used
string$tableNameName of the table to be registered
string$fieldNameName of the field to be registered
array$optionsAdditional configuration options
  • fieldList: field configuration to be added to showitems
  • typesList: list of types that shall visualize the categories field
  • position: insert position of the categories field
  • label: backend label of the categories field
  • fieldConfiguration: TCA field config array to override defaults
bool$overrideIf TRUE, any category configuration for the same table / field is removed before the new configuration is added
Returns
bool
Exceptions
InvalidArgumentException
RuntimeException

Definition at line 85 of file CategoryRegistry.php.

References $GLOBALS, CategoryRegistry\applyTcaForTableAndField(), and CategoryRegistry\isRegistered().

Referenced by CategoryRegistry\registerDefaultCategorizedTables().

addCategoryDatabaseSchemaToTablesDefinition ( array  $sqlString)

A slot method to inject the required category database fields to the tables definition string

Parameters
array$sqlString
Returns
array

Definition at line 441 of file CategoryRegistry.php.

References CategoryRegistry\getDatabaseTableDefinitions(), and CategoryRegistry\registerDefaultCategorizedTables().

addCategoryTab (   $tableName,
  $fieldName 
)
protected

Creates the 'fieldList' string for $fieldName which includes a categories tab. But only one categories tab is added per table.

Parameters
string$tableName
string$fieldName
Returns
string

Definition at line 304 of file CategoryRegistry.php.

Referenced by CategoryRegistry\addToAllTCAtypes().

addExtensionCategoryDatabaseSchemaToTablesDefinition ( array  $sqlString,
  $extensionKey 
)

A slot method to inject the required category database fields of an extension to the tables definition string

Parameters
array$sqlString
string$extensionKey
Returns
array

Definition at line 456 of file CategoryRegistry.php.

References CategoryRegistry\getDatabaseTableDefinition().

addTcaColumn (   $tableName,
  $fieldName,
array  $options 
)
protected

Add a new TCA Column

Parameters
string$tableNameName of the table to be categorized
string$fieldNameName of the field to be used to store categories
array$optionsAdditional configuration options
  • fieldConfiguration: TCA field config array to override defaults
  • label: backend label of the categories field
  • interface: boolean if the category should be included in the "interface" section of the TCA table
  • l10n_mode
  • l10n_display
Returns
void

Definition at line 328 of file CategoryRegistry.php.

References $GLOBALS, ExtensionManagementUtility\addTCAcolumns(), and GeneralUtility\inList().

Referenced by CategoryRegistry\applyTcaForTableAndField().

addToAllTCAtypes (   $tableName,
  $fieldName,
array  $options 
)
protected

Add a new field into the TCA types -> showitem

Parameters
string$tableNameName of the table to be categorized
string$fieldNameName of the field to be used to store categories
array$optionsAdditional configuration options
  • fieldList: field configuration to be added to showitems
  • typesList: list of types that shall visualize the categories field
  • position: insert position of the categories field
Returns
void

Definition at line 270 of file CategoryRegistry.php.

References $GLOBALS, CategoryRegistry\addCategoryTab(), and ExtensionManagementUtility\addToAllTCAtypes().

Referenced by CategoryRegistry\applyTcaForTableAndField().

applyTcaForPreRegisteredTables ( )

Apply TCA to all registered tables

Returns
void

Definition at line 218 of file CategoryRegistry.php.

References $fields, CategoryRegistry\applyTcaForTableAndField(), and CategoryRegistry\registerDefaultCategorizedTables().

applyTcaForTableAndField (   $tableName,
  $fieldName 
)
protected

Applies the additions directly to the TCA

Parameters
string$tableName
string$fieldName

Definition at line 234 of file CategoryRegistry.php.

References CategoryRegistry\addTcaColumn(), and CategoryRegistry\addToAllTCAtypes().

Referenced by CategoryRegistry\add(), and CategoryRegistry\applyTcaForPreRegisteredTables().

getCategorizedTables ( )

Gets all categorized tables

Returns
array

Definition at line 127 of file CategoryRegistry.php.

getCategoryFieldsForTable ( array &  $configuration)

Returns a list of category fields for a given table for populating selector "category_field" in tt_content table (called as itemsProcFunc).

Parameters
array$configurationCurrent field configuration
Exceptions
UnexpectedValueException
Returns
void

Definition at line 140 of file CategoryRegistry.php.

References $fields, $GLOBALS, and CategoryRegistry\getLanguageService().

getDatabaseTableDefinition (   $extensionKey)

Generates table definitions for registered tables by an extension.

Parameters
string$extensionKeyExtension key to have the database definitions created for
Returns
string

Definition at line 197 of file CategoryRegistry.php.

References $fields.

Referenced by CategoryRegistry\addExtensionCategoryDatabaseSchemaToTablesDefinition(), and CategoryRegistry\getDatabaseTableDefinitions().

getDatabaseTableDefinitions ( )

Generates tables definitions for all registered tables.

Returns
string

Definition at line 182 of file CategoryRegistry.php.

References CategoryRegistry\getDatabaseTableDefinition(), and CategoryRegistry\getExtensionKeys().

Referenced by CategoryRegistry\addCategoryDatabaseSchemaToTablesDefinition().

getExtensionKeys ( )

Gets all extension keys that registered a category configuration.

Returns
array

Definition at line 117 of file CategoryRegistry.php.

Referenced by CategoryRegistry\getDatabaseTableDefinitions().

static getInstance ( )
static
getLanguageService ( )
protected
Returns
LanguageService

Definition at line 465 of file CategoryRegistry.php.

References $GLOBALS.

Referenced by CategoryRegistry\getCategoryFieldsForTable().

static getTcaFieldConfiguration (   $tableName,
  $fieldName = 'categories',
array  $fieldConfigurationOverride = [] 
)
static

Get the config array for given table and field. This method does NOT take care of adding sql fields, adding the field to TCA types nor does it set the MM_oppositeUsage in the sys_category TCA. This has to be taken care of manually!

Parameters
string$tableNameThe table name
string$fieldNameThe field name (default categories)
array$fieldConfigurationOverrideChanges to the default configuration
Returns
array

Definition at line 397 of file CategoryRegistry.php.

References ArrayUtility\mergeRecursiveWithOverrule().

isRegistered (   $tableName,
  $fieldName = 'categories' 
)

Tells whether a table has a category configuration in the registry.

Parameters
string$tableNameName of the table to be looked up
string$fieldNameName of the field to be looked up
Returns
bool

Definition at line 172 of file CategoryRegistry.php.

Referenced by CategoryRegistry\add(), CategoryRegistry\registerDefaultCategorizedTables(), and CategoryRegistry\remove().

registerDefaultCategorizedTables ( )
protected
remove (   $tableName,
  $fieldName 
)
protected

Removes the given field in the given table from the registry if it is found.

Parameters
string$tableNameThe name of the table for which the registration should be removed.
string$fieldNameThe name of the field for which the registration should be removed.

Definition at line 476 of file CategoryRegistry.php.

References CategoryRegistry\isRegistered().

Member Data Documentation

$addedCategoryTabs = []
protected

Definition at line 41 of file CategoryRegistry.php.

$extensions = []
protected

Definition at line 36 of file CategoryRegistry.php.

$registry = []
protected

Definition at line 31 of file CategoryRegistry.php.

$template = ''
protected

Definition at line 46 of file CategoryRegistry.php.