TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Imaging\IconFactory Class Reference

Public Member Functions

 __construct (IconRegistry $iconRegistry=null)
 
 processAjaxRequest (ServerRequestInterface $request, ResponseInterface $response)
 
 getIconForRecord ($table, array $row, $size=Icon::SIZE_DEFAULT)
 
 mapRecordTypeToIconIdentifier ($table, array $row)
 
 getIconForFileExtension ($fileExtension, $size=Icon::SIZE_DEFAULT, $overlayIdentifier=null)
 
 getIconForResource (ResourceInterface $resource, $size=Icon::SIZE_DEFAULT, $overlayIdentifier=null, array $options=[])
 

Protected Member Functions

 mapRecordTypeToOverlayIdentifier ($table, array $row)
 
 createIcon ($identifier, $size, $overlayIdentifier=null, array $iconConfiguration=[])
 
 emitBuildIconForResourceSignal (ResourceInterface $resource, $size, array $options, $iconIdentifier, $overlayIdentifier)
 
 getSignalSlotDispatcher ()
 

Protected Attributes

 $iconRegistry
 
 $recordStatusMapping = []
 
 $overlayPriorities = []
 

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 ( IconRegistry  $iconRegistry = null)

Member Function Documentation

◆ createIcon()

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$iconConfigurationthe icon configuration array
Returns
Icon

Definition at line 468 of file IconFactory.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Imaging\Icon\SIZE_OVERLAY.

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

◆ emitBuildIconForResourceSignal()

TYPO3\CMS\Core\Imaging\IconFactory::emitBuildIconForResourceSignal ( ResourceInterface  $resource,
  $size,
array  $options,
  $iconIdentifier,
  $overlayIdentifier 
)
protected

Emits a signal right after the identifiers are built.

Parameters
ResourceInterface$resource
string$size
array$options
string$iconIdentifier
string$overlayIdentifier
Returns
mixed
Exceptions

Definition at line 496 of file IconFactory.php.

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

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

◆ getIconForFileExtension()

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

Referenced by TYPO3\CMS\Documentation\ViewHelpers\FormatsViewHelper\getIconForFileExtension().

◆ getIconForRecord()

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$tableThe TCA table name
array$rowThe DB record of the TCA table
string$size"large" "small" or "default", see the constants of the Icon class
Returns
Icon

Definition at line 131 of file IconFactory.php.

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

◆ getIconForResource()

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$optionsAn associative array with additional options.
Returns
Icon

Definition at line 368 of file IconFactory.php.

References TYPO3\CMS\Core\Imaging\IconFactory\emitBuildIconForResourceSignal(), 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.

◆ getSignalSlotDispatcher()

TYPO3\CMS\Core\Imaging\IconFactory::getSignalSlotDispatcher ( )
protected

Get the SignalSlot dispatcher

Returns

Definition at line 518 of file IconFactory.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

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

◆ mapRecordTypeToIconIdentifier()

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$tableThe TCA table
array$rowThe selected record

Definition at line 157 of file IconFactory.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\callUserFunction().

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

◆ mapRecordTypeToOverlayIdentifier()

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$tableThe TCA table
array$rowThe selected record
Returns
string The status with the highest priority

Definition at line 258 of file IconFactory.php.

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

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

◆ processAjaxRequest()

TYPO3\CMS\Core\Imaging\IconFactory::processAjaxRequest ( ServerRequestInterface  $request,
ResponseInterface  $response 
)

Member Data Documentation

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

TYPO3\CMS\Core\Imaging\IconFactory::$overlayPriorities = []
protected

Definition at line 53 of file IconFactory.php.

◆ $recordStatusMapping

TYPO3\CMS\Core\Imaging\IconFactory::$recordStatusMapping = []
protected

Definition at line 45 of file IconFactory.php.