‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Imaging\IconFactory Class Reference

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher, IconRegistry $iconRegistry, ContainerInterface $container)
 
Icon getIcon ($identifier, string|IconSize $size=IconSize::MEDIUM, $overlayIdentifier=null, \TYPO3\CMS\Core\Type\Icon\IconState|IconState $state=null)
 
Icon getIconForRecord ($table, array $row, $size=IconSize::MEDIUM)
 
string mapRecordTypeToIconIdentifier ($table, array $row)
 
Icon getIconForFileExtension ($fileExtension, string|IconSize $size=IconSize::MEDIUM, $overlayIdentifier=null)
 
Icon getIconForResource (ResourceInterface $resource, string|IconSize $size=IconSize::MEDIUM, $overlayIdentifier=null, array $options=[])
 
 clearIconCache ()
 

Protected Member Functions

 getIconForPlugin (string $pluginName)
 
 getRecordTypeForPageType (string $typeName, string $suffix, string $table, string $fallbackTypeName='1')
 
string mapRecordTypeToOverlayIdentifier ($table, array $row)
 
Icon createIcon ($identifier, IconSize $size, $overlayIdentifier=null, array $iconConfiguration=[])
 

Protected Attributes

IconRegistry $iconRegistry
 
string[] $recordStatusMapping = array( )
 
string[] $overlayPriorities = array( )
 
EventDispatcherInterface $eventDispatcher
 
ContainerInterface $container
 

Static Protected Attributes

static array $iconCache = array( )
 

Detailed Description

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.

Definition at line 33 of file IconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Imaging\IconFactory::__construct ( EventDispatcherInterface  $eventDispatcher,
IconRegistry  $iconRegistry,
ContainerInterface  $container 
)

Member Function Documentation

◆ clearIconCache()

TYPO3\CMS\Core\Imaging\IconFactory::clearIconCache ( )

clear icon cache

Definition at line 561 of file IconFactory.php.

◆ createIcon()

Icon TYPO3\CMS\Core\Imaging\IconFactory::createIcon (   $identifier,
IconSize  $size,
  $overlayIdentifier = null,
array  $iconConfiguration = [] 
)
protected

Creates an icon object

Parameters
string$identifier
IconSize$size
string$overlayIdentifier
array$iconConfiguration‪the icon configuration array
Returns
Icon

Definition at line 541 of file IconFactory.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Core\Imaging\IconFactory\getIcon().

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\getIcon().

◆ getIcon()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIcon (   $identifier,
string|IconSize  $size = IconSize::MEDIUM,
  $overlayIdentifier = null,
\TYPO3\CMS\Core\Type\Icon\IconState|IconState  $state = null 
)

◆ getIconForFileExtension()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIconForFileExtension (   $fileExtension,
string|IconSize  $size = IconSize::MEDIUM,
  $overlayIdentifier = null 
)

Get Icon for a file by its extension

Parameters
string$fileExtension
string | IconSize$size
string$overlayIdentifier
Returns
Icon
Todo:
‪: Change $size to allow IconSize only in v14

Definition at line 403 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\getIcon().

◆ getIconForPlugin()

TYPO3\CMS\Core\Imaging\IconFactory::getIconForPlugin ( string  $pluginName)
protected

Returns a possible configured icon for the given plugin name

Definition at line 287 of file IconFactory.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\mapRecordTypeToIconIdentifier().

◆ getIconForRecord()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIconForRecord (   $table,
array  $row,
  $size = IconSize::MEDIUM 
)

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

Parameters
string$table‪The TCA table name
array$row‪The DB record of the TCA table
string | IconSize$size
Returns
Icon
Todo:
‪: Change $size to allow IconSize only in v14

Definition at line 136 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\getIcon(), TYPO3\CMS\Core\Imaging\IconFactory\mapRecordTypeToIconIdentifier(), and TYPO3\CMS\Core\Imaging\IconFactory\mapRecordTypeToOverlayIdentifier().

◆ getIconForResource()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIconForResource ( ResourceInterface  $resource,
string|IconSize  $size = IconSize::MEDIUM,
  $overlayIdentifier = null,
array  $options = [] 
)

This method is used throughout the TYPO3 Backend to show icons for files and folders

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
ResourceInterface$resource
string | IconSize$size
string$overlayIdentifier
array$options‪An associative array with additional options.
Returns
Icon
Todo:
‪: Change $size to allow IconSize only in v14

Definition at line 433 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\getIcon(), TYPO3\CMS\Core\Resource\ResourceInterface\getIdentifier(), TYPO3\CMS\Core\Resource\ResourceInterface\getStorage(), TYPO3\CMS\Core\Resource\FolderInterface\ROLE_READONLY_MOUNT, TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER, TYPO3\CMS\Core\Resource\FolderInterface\ROLE_TEMPORARY, and TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USER_MOUNT.

◆ getRecordTypeForPageType()

TYPO3\CMS\Core\Imaging\IconFactory::getRecordTypeForPageType ( string  $typeName,
string  $suffix,
string  $table,
string  $fallbackTypeName = '1' 
)
protected

Returns recordType for icon based on a typeName and a suffix. Fallback to page as typeName if resulting type is not configured.

Definition at line 305 of file IconFactory.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\mapRecordTypeToIconIdentifier().

◆ mapRecordTypeToIconIdentifier()

string TYPO3\CMS\Core\Imaging\IconFactory::mapRecordTypeToIconIdentifier (   $table,
array  $row 
)

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. 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
string$table‪The TCA table
array$row‪The selected record

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

Returns
‪string The icon identifier string for the icon of that DB record

Definition at line 163 of file IconFactory.php.

References $GLOBALS, TYPO3\CMS\Core\Imaging\IconFactory\getIconForPlugin(), and TYPO3\CMS\Core\Imaging\IconFactory\getRecordTypeForPageType().

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\getIconForRecord().

◆ mapRecordTypeToOverlayIdentifier()

string TYPO3\CMS\Core\Imaging\IconFactory::mapRecordTypeToOverlayIdentifier (   $table,
array  $row 
)
protected

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

Parameters
string$table‪The TCA table
array$row‪The selected record
Returns
‪string The status with the highest priority

Definition at line 325 of file IconFactory.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\getIconForRecord().

Member Data Documentation

◆ $container

ContainerInterface TYPO3\CMS\Core\Imaging\IconFactory::$container
protected

Definition at line 63 of file IconFactory.php.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\__construct().

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Core\Imaging\IconFactory::$eventDispatcher
protected

Definition at line 61 of file IconFactory.php.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\__construct().

◆ $iconCache

array TYPO3\CMS\Core\Imaging\IconFactory::$iconCache = array( )
staticprotected

Runtime icon cache

Definition at line 57 of file IconFactory.php.

◆ $iconRegistry

IconRegistry TYPO3\CMS\Core\Imaging\IconFactory::$iconRegistry
protected

Definition at line 37 of file IconFactory.php.

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\__construct().

◆ $overlayPriorities

string [] TYPO3\CMS\Core\Imaging\IconFactory::$overlayPriorities = array( )
protected

Order of priorities for overlays. $GLOBALS['TYPO3_CONF_VARS']['SYS']['IconFactory']['overlayPriorities']

Definition at line 51 of file IconFactory.php.

◆ $recordStatusMapping

string [] TYPO3\CMS\Core\Imaging\IconFactory::$recordStatusMapping = array( )
protected

Mapping of record status to overlays. $GLOBALS['TYPO3_CONF_VARS']['SYS']['IconFactory']['recordStatusMapping']

Definition at line 44 of file IconFactory.php.