TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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=array())
 

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

Definition at line 74 of file IconFactory.php.

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

Member Function Documentation

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 454 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\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
\TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException

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

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

getIconForResource ( ResourceInterface  $resource,
  $size = Icon::SIZE_DEFAULT,
  $overlayIdentifier = null,
array  $options = array() 
)

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

References elseif, 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 495 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 173 of file IconFactory.php.

References $GLOBALS, GeneralUtility\callUserFunction(), and elseif.

Referenced by IconFactory\getIconForRecord().

mapRecordTypeToOverlayIdentifier (   $table,
array  $row 
)
protected

This helper functions 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 261 of file IconFactory.php.

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

Referenced by IconFactory\getIconForRecord().

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

Definition at line 85 of file IconFactory.php.

References $response, Enumeration\cast(), MessageInterface\getBody(), ServerRequestInterface\getParsedBody(), ServerRequestInterface\getQueryParams(), and MessageInterface\withHeader().

Member Data Documentation

$iconRegistry
protected

Definition at line 37 of file IconFactory.php.

Referenced by IconFactory\__construct().

$overlayPriorities
protected
Initial value:
= array(
'hidden',
'starttime',
'endtime',
'futureendtime',
'protectedSection',
'fe_group'
)

Definition at line 62 of file IconFactory.php.

$recordStatusMapping
protected
Initial value:
= array(
'hidden' => 'overlay-hidden',
'fe_group' => 'overlay-restricted',
'starttime' => 'overlay-scheduled',
'endtime' => 'overlay-scheduled',
'futureendtime' => 'overlay-scheduled',
'readonly' => 'overlay-readonly',
'deleted' => 'overlay-deleted',
'missing' => 'overlay-missing',
'translated' => 'overlay-translated',
'protectedSection' => 'overlay-includes-subpages'
)

Definition at line 44 of file IconFactory.php.