IconFactory

readonly class \TYPO3\CMS\Core\Imaging\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

clearIconCache()

public clearIconCache() : void

getIconForFileExtension()

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

todo:

Change $size to allow IconSize only in v14

Return values

Icon

getIconForRecord()

This method is used throughout the TYPO3 Backend to show icons for a DB record

public getIconForRecord(string $table, array $row[, string|IconSize $size = IconSize::MEDIUM ]) : Icon

Parameters

$table : string

The TCA table name

$row : array

The DB record of the TCA table

$size : string|IconSize = IconSize::MEDIUM

Tags

todo:

Change $size to allow IconSize only in v14

Return values

Icon

getIconForResource()

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 $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 = []

An associative array with additional options.

Tags

todo:

Change $size to allow IconSize only in v14

Return values

Icon

mapRecordTypeToIconIdentifier()

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 $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

The selected record

Tags

TODO:

make this method protected, after FormEngine doesn't need it anymore.

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 $iconConfiguration = [] ]) : Icon

Parameters

$identifier : string
$size : IconSize
$overlayIdentifier : string|null = null
$iconConfiguration : array = []

the icon configuration array

Return values

Icon

getIconForPlugin()

Returns a possible configured icon for the given plugin name

protected getIconForPlugin(string $pluginName) : string|null

Parameters

$pluginName : string

Return values

string|null

getRecordTypeForPageType()

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

string

mapRecordTypeToOverlayIdentifier()

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 $row) : string

Parameters

$table : string

The TCA table

$row : array

The selected record

Return values

string —

The status with the highest priority

On this page