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

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher, IconRegistry $iconRegistry)
 
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 getRecordTypeForPageType (string $typeName, string $suffix, string $table)
 
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
 

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 32 of file IconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 66 of file IconFactory.php.

References 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 501 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 482 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 
)

◆ 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 355 of file IconFactory.php.

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

◆ 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 117 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\Backend\Tree\View\PagePositionMap\getRecordHeader().

◆ 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 379 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 
)
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 252 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 140 of file IconFactory.php.

References $GLOBALS, 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 272 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

◆ $eventDispatcher

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

Definition at line 60 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 56 of file IconFactory.php.

◆ $iconRegistry

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

Definition at line 36 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 50 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 43 of file IconFactory.php.