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

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher, IconRegistry $iconRegistry, ContainerInterface $container)
 
Icon getIcon ($identifier, $size=Icon::SIZE_DEFAULT, $overlayIdentifier=null, ?IconState $state=null)
 
Icon getIconForRecord ($table, array $row, $size=Icon::SIZE_DEFAULT)
 
string mapRecordTypeToIconIdentifier ($table, array $row)
 
Icon getIconForFileExtension ($fileExtension, $size=Icon::SIZE_DEFAULT, $overlayIdentifier=null)
 
Icon getIconForResource (ResourceInterface $resource, $size=Icon::SIZE_DEFAULT, $overlayIdentifier=null, array $options=[])
 
 clearIconCache ()
 

Protected Member Functions

string null getIconForPlugin (string $pluginName)
 
string getRecordTypeForPageType (string $typeName, string $suffix, string $table, string $fallbackTypeName='1')
 
string mapRecordTypeToOverlayIdentifier ($table, array $row)
 
Icon createIcon ($identifier, $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 
)
Parameters
EventDispatcherInterface$eventDispatcher
IconRegistry$iconRegistry
ContainerInterface$container

Definition at line 70 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\$container, TYPO3\CMS\Core\Imaging\IconFactory\$eventDispatcher, $GLOBALS, and TYPO3\CMS\Core\Imaging\IconFactory\$iconRegistry.

Member Function Documentation

◆ clearIconCache()

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

clear icon cache

Definition at line 544 of file IconFactory.php.

◆ createIcon()

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

Creates an icon object

Parameters
string$identifier
string$size‪"large", "small" or "default", see the constants of the Icon class
string$overlayIdentifier
array$iconConfiguration‪the icon configuration array
Returns
Icon

Definition at line 525 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\getIcon(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_OVERLAY.

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

◆ getIcon()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIcon (   $identifier,
  $size = Icon::SIZE_DEFAULT,
  $overlayIdentifier = null,
?IconState  $state = null 
)
Parameters
string$identifier
string$size‪"large", "small" or "default", see the constants of the Icon class
string$overlayIdentifier
IconState$state
Returns
Icon

Definition at line 86 of file IconFactory.php.

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

Referenced by TYPO3\CMS\Core\Imaging\IconFactory\createIcon(), TYPO3\CMS\Core\Imaging\IconFactory\getIconForFileExtension(), TYPO3\CMS\Core\Imaging\IconFactory\getIconForRecord(), and TYPO3\CMS\Core\Imaging\IconFactory\getIconForResource().

◆ getIconForFileExtension()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIconForFileExtension (   $fileExtension,
  $size = Icon::SIZE_DEFAULT,
  $overlayIdentifier = null 
)

Get Icon for a file by its extension

Parameters
string$fileExtension
string$size‪"large" "small" or "default", see the constants of the Icon class
string$overlayIdentifier
Returns
Icon

Definition at line 398 of file IconFactory.php.

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

◆ getIconForPlugin()

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

Returns a possible configured icon for the given plugin name

Parameters
string$pluginName
Returns
‪string|null

Definition at line 273 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 = Icon::SIZE_DEFAULT 
)

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$size‪"large" "small" or "default", see the constants of the Icon class
Returns
Icon

Definition at line 124 of file IconFactory.php.

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

Referenced by TYPO3\CMS\Form\Controller\FormManagerController\getProcessedReferencesRows().

◆ getIconForResource()

Icon TYPO3\CMS\Core\Imaging\IconFactory::getIconForResource ( ResourceInterface  $resource,
  $size = Icon::SIZE_DEFAULT,
  $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$size‪"large" "small" or "default", see the constants of the Icon class
string$overlayIdentifier
array$options‪An associative array with additional options.
Returns
Icon

Definition at line 422 of file IconFactory.php.

References TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission(), TYPO3\CMS\Core\Imaging\IconFactory\getIcon(), TYPO3\CMS\Core\Resource\ResourceInterface\getIdentifier(), TYPO3\CMS\Core\Resource\Folder\getIdentifier(), TYPO3\CMS\Core\Resource\ResourceStorage\getRootLevelFolder(), TYPO3\CMS\Core\Resource\ResourceInterface\getStorage(), TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable(), 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()

string 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.

Parameters
string$typeName
string$suffix
string$table
Returns
‪string

Definition at line 295 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 147 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 315 of file IconFactory.php.

References $GLOBALS, TYPO3\CMS\Core\Type\Enumeration\cast(), and TYPO3\CMS\Core\Versioning\VersionState\DELETE_PLACEHOLDER.

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.