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
Methods
- __construct() : mixed
- clearIconCache() : void
- 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
Methods
__construct()
public
__construct(EventDispatcherInterface $eventDispatcher, IconRegistry $iconRegistry, ContainerInterface $container, FrontendInterface $runtimeCache) : mixed
Parameters
- $eventDispatcher : EventDispatcherInterface
- $iconRegistry : IconRegistry
- $container : ContainerInterface
- $runtimeCache : FrontendInterface
clearIconCache()
public
clearIconCache() : void
Remove in v14. May have been used during testing in TYPO3 <v14.
getIcon()
public
getIcon(string $identifier[, string|IconSize $size = IconSize::MEDIUM ][, string|null $overlayIdentifier = null ][, IconState|IconState|null $state = null ]) : Icon
Parameters
- $identifier : string
- $size : string|IconSize = IconSize::MEDIUM
- $overlayIdentifier : string|null = null
- $state : IconState|IconState|null = null
Tags
Return values
IcongetIconForFileExtension()
Get Icon for a file by its extension
public
getIconForFileExtension(string $fileExtension[, string|IconSize $size = IconSize::MEDIUM ][, string|null $overlayIdentifier = null ]) : Icon
Parameters
- $fileExtension : string
- $size : string|IconSize = IconSize::MEDIUM
- $overlayIdentifier : string|null = null
Tags
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|IconSize $size = IconSize::MEDIUM ]) : Icon
Parameters
- $table : string
-
The TCA table name
- $row : array<string|int, mixed>
-
The DB record of the TCA table
- $size : string|IconSize = IconSize::MEDIUM
Tags
Return values
IcongetIconForResource()
This method is used throughout the TYPO3 Backend to show icons for files and folders
public
getIconForResource(ResourceInterface $resource[, string|IconSize $size = IconSize::MEDIUM ][, string|null $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|IconSize = IconSize::MEDIUM
- $overlayIdentifier : string|null = null
- $options : array<string|int, mixed> = []
-
An associative array with additional options.
Tags
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, IconSize $size[, string|null $overlayIdentifier = null ][, array<string|int, mixed> $iconConfiguration = [] ]) : Icon
Parameters
- $identifier : string
- $size : IconSize
- $overlayIdentifier : string|null = 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