TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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=[])
 
 clearIconCache ()
 

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

Static Protected Attributes

static $iconCache = []
 

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

Definition at line 65 of file IconFactory.php.

References $GLOBALS, IconFactory\$iconRegistry, and GeneralUtility\makeInstance().

Member Function Documentation

clearIconCache ( )

clear icon cache

Definition at line 528 of file IconFactory.php.

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

References GeneralUtility\makeInstance(), and Icon\SIZE_OVERLAY.

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

Definition at line 498 of file IconFactory.php.

References IconFactory\getSignalSlotDispatcher().

Referenced by IconFactory\getIconForResource().

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

Referenced by FormatsViewHelper\getIconForFileExtension().

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

References IconFactory\mapRecordTypeToIconIdentifier(), and IconFactory\mapRecordTypeToOverlayIdentifier().

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

References IconFactory\emitBuildIconForResourceSignal(), ResourceInterface\getIdentifier(), ResourceInterface\getStorage(), FolderInterface\ROLE_READONLY_MOUNT, FolderInterface\ROLE_RECYCLER, FolderInterface\ROLE_TEMPORARY, and FolderInterface\ROLE_USER_MOUNT.

getSignalSlotDispatcher ( )
protected

Get the SignalSlot dispatcher

Returns

Definition at line 520 of file IconFactory.php.

References GeneralUtility\makeInstance().

Referenced by IconFactory\emitBuildIconForResourceSignal().

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

References $GLOBALS, and GeneralUtility\callUserFunction().

Referenced by IconFactory\getIconForRecord().

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

References $GLOBALS, Enumeration\cast(), VersionState\DELETE_PLACEHOLDER, and GeneralUtility\getUserObj().

Referenced by IconFactory\getIconForRecord().

processAjaxRequest ( ServerRequestInterface  $request,
ResponseInterface  $response 
)
Parameters
ServerRequestInterface$request
ResponseInterface$response
Returns
string

Definition at line 78 of file IconFactory.php.

References Enumeration\cast().

Member Data Documentation

$iconCache = []
staticprotected

Definition at line 60 of file IconFactory.php.

$iconRegistry
protected

Definition at line 37 of file IconFactory.php.

Referenced by IconFactory\__construct().

$overlayPriorities = []
protected

Definition at line 53 of file IconFactory.php.

$recordStatusMapping = []
protected

Definition at line 45 of file IconFactory.php.