IconFactory
The main factory class, which acts as the entrypoint for generating an Icon object which is responsible for rendering an icon. Checks for the correct icon provider through the IconRegistry.
Table of Contents
Properties
- $container : ContainerInterface
- $eventDispatcher : EventDispatcherInterface
- $iconCache : array<string|int, mixed>
- Runtime icon cache
- $iconRegistry : IconRegistry
- $overlayPriorities : array<string|int, string>
- Order of priorities for overlays.
- $recordStatusMapping : array<string|int, string>
- Mapping of record status to overlays.
Methods
- __construct() : mixed
- clearIconCache() : mixed
- clear icon cache
- getIcon() : Icon
- getIconForFileExtension() : Icon
- Get Icon for a file by its extension
- getIconForRecord() : Icon
- This method is used throughout the TYPO3 Backend to show icons for a DB record
- getIconForResource() : Icon
- This method is used throughout the TYPO3 Backend to show icons for files and folders
- mapRecordTypeToIconIdentifier() : string
- This helper functions looks up the column that is used for the type of the chosen TCA table and then fetches the corresponding iconName based on the chosen icon class in this TCA.
- createIcon() : Icon
- Creates an icon object
- getIconForPlugin() : string|null
- Returns a possible configured icon for the given plugin name
- getRecordTypeForPageType() : string
- Returns recordType for icon based on a typeName and a suffix.
- mapRecordTypeToOverlayIdentifier() : string
- This helper function checks if the DB record ($row) has any special status based on the TCA settings like hidden, starttime etc, and then returns a specific icon overlay identifier for the overlay of this DB record This method solely takes care of the overlay of this record, not any type
Properties
$container
protected
ContainerInterface
$container
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$iconCache
Runtime icon cache
protected
static array<string|int, mixed>
$iconCache
= []
$iconRegistry
protected
IconRegistry
$iconRegistry
$overlayPriorities
Order of priorities for overlays.
protected
array<string|int, string>
$overlayPriorities
= []
$GLOBALS['TYPO3_CONF_VARS']['SYS']['IconFactory']['overlayPriorities']
$recordStatusMapping
Mapping of record status to overlays.
protected
array<string|int, string>
$recordStatusMapping
= []
$GLOBALS['TYPO3_CONF_VARS']['SYS']['IconFactory']['recordStatusMapping']
Methods
__construct()
public
__construct(EventDispatcherInterface $eventDispatcher, IconRegistry $iconRegistry, ContainerInterface $container) : mixed
Parameters
- $eventDispatcher : EventDispatcherInterface
- $iconRegistry : IconRegistry
- $container : ContainerInterface
clearIconCache()
clear icon cache
public
clearIconCache() : mixed
getIcon()
public
getIcon(string $identifier[, string $size = Icon::SIZE_MEDIUM ][, string $overlayIdentifier = null ][, IconState|null $state = null ]) : Icon
Parameters
- $identifier : string
- $size : string = Icon::SIZE_MEDIUM
-
"default", "small", "medium" or "large", see the constants of the Icon class
- $overlayIdentifier : string = null
- $state : IconState|null = null
Return values
IcongetIconForFileExtension()
Get Icon for a file by its extension
public
getIconForFileExtension(string $fileExtension[, string $size = Icon::SIZE_MEDIUM ][, string $overlayIdentifier = null ]) : Icon
Parameters
- $fileExtension : string
- $size : string = Icon::SIZE_MEDIUM
-
"large" "small" or "default", see the constants of the Icon class
- $overlayIdentifier : string = null
Return values
IcongetIconForRecord()
This method is used throughout the TYPO3 Backend to show icons for a DB record
public
getIconForRecord(string $table, array<string|int, mixed> $row[, string $size = Icon::SIZE_MEDIUM ]) : Icon
Parameters
- $table : string
-
The TCA table name
- $row : array<string|int, mixed>
-
The DB record of the TCA table
- $size : string = Icon::SIZE_MEDIUM
-
"default", "small", "medium" or "large", see the constants of the Icon class
Return values
IcongetIconForResource()
This method is used throughout the TYPO3 Backend to show icons for files and folders
public
getIconForResource(ResourceInterface $resource[, string $size = Icon::SIZE_MEDIUM ][, string $overlayIdentifier = null ][, array<string|int, mixed> $options = [] ]) : Icon
The method takes care of the translation of file extension to proper icon and for folders it will return the icon depending on the role of the folder.
If the given resource is a folder there are some additional options that can be used:
- mount-root => TRUE (to indicate this is the root of a mount)
- folder-open => TRUE (to indicate that the folder is opened in the file tree)
There is a hook in place to manipulate the icon name and overlays.
Parameters
- $resource : ResourceInterface
- $size : string = Icon::SIZE_MEDIUM
-
"large" "small" or "default", see the constants of the Icon class
- $overlayIdentifier : string = null
- $options : array<string|int, mixed> = []
-
An associative array with additional options.
Return values
IconmapRecordTypeToIconIdentifier()
This helper functions looks up the column that is used for the type of the chosen TCA table and then fetches the corresponding iconName based on the chosen icon class in this TCA.
public
mapRecordTypeToIconIdentifier(string $table, array<string|int, mixed> $row) : string
The TCA looks up
- [ctrl][typeicon_column]
This method solely takes care of the type of this record, not any statuses used for overlays.
see EXT:core/Configuration/TCA/pages.php for an example with the TCA table "pages"
Parameters
- $table : string
-
The TCA table
- $row : array<string|int, mixed>
-
The selected record
Tags
Return values
string —The icon identifier string for the icon of that DB record
createIcon()
Creates an icon object
protected
createIcon(string $identifier, string $size[, string $overlayIdentifier = null ][, array<string|int, mixed> $iconConfiguration = [] ]) : Icon
Parameters
- $identifier : string
- $size : string
-
"large", "small" or "default", see the constants of the Icon class
- $overlayIdentifier : string = null
- $iconConfiguration : array<string|int, mixed> = []
-
the icon configuration array
Return values
IcongetIconForPlugin()
Returns a possible configured icon for the given plugin name
protected
getIconForPlugin(string $pluginName) : string|null
Parameters
- $pluginName : string
Return values
string|nullgetRecordTypeForPageType()
Returns recordType for icon based on a typeName and a suffix.
protected
getRecordTypeForPageType(string $typeName, string $suffix, string $table[, string $fallbackTypeName = '1' ]) : string
Fallback to page as typeName if resulting type is not configured.
Parameters
- $typeName : string
- $suffix : string
- $table : string
- $fallbackTypeName : string = '1'
Return values
stringmapRecordTypeToOverlayIdentifier()
This helper function checks if the DB record ($row) has any special status based on the TCA settings like hidden, starttime etc, and then returns a specific icon overlay identifier for the overlay of this DB record This method solely takes care of the overlay of this record, not any type
protected
mapRecordTypeToOverlayIdentifier(string $table, array<string|int, mixed> $row) : string
Parameters
- $table : string
-
The TCA table
- $row : array<string|int, mixed>
-
The selected record
Return values
string —The status with the highest priority