Skip to content

Commit

Permalink
[TASK] Refactor ContentIconHookSubscriber cache usage
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Feb 23, 2015
1 parent 35450a3 commit e678e7a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Classes/Hooks/ContentIconHookSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ public function __construct() {
public function addSubIcon(array $parameters, $caller = NULL) {
list ($table, $uid, $record) = $parameters;
$icon = NULL;
if (NULL === $record && 0 < $uid) {
$record = BackendUtility::getRecord($table, $uid);
}
$record = NULL === $record && 0 < $uid ? BackendUtility::getRecord($table, $uid) : $record;
$cacheIdentity = $table . $uid . sha1(serialize($record));
// filter 1: icon must not already be cached and both record and caller must be provided.
if (TRUE === $this->cache->has($cacheIdentity)) {
Expand All @@ -106,7 +104,7 @@ public function addSubIcon(array $parameters, $caller = NULL) {
$form = $provider->getForm((array) $record);
if (NULL !== $form) {
$icon = MiscellaneousUtility::getIconForTemplate($form);
if (FALSE === empty($icon)) {
if (NULL !== $icon) {
$iconFileReference = '../../../' . $icon;
$label = trim($form->getLabel());
$icon = '<img width="16" height="16" src="' . $iconFileReference . '" alt="' . $label . '"
Expand All @@ -117,8 +115,8 @@ public function addSubIcon(array $parameters, $caller = NULL) {
}
}
}
$this->cache->set($cacheIdentity, $icon);
}
$this->cache->set($cacheIdentity, $icon);
return $icon;
}

Expand Down

0 comments on commit e678e7a

Please sign in to comment.