Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
[BUGFIX] Render correct icon in content type selector
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Aug 13, 2017
1 parent f0b6fe5 commit 9d0ab22
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Classes/Helper/ContentTypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,29 +174,33 @@ public function registerContentType(
$controllerExtensionName = 'FluidTYPO3.Flux';
}
$this->registerExtbasePluginForForm($controllerExtensionName, $pluginName, $form);
$this->addPageTsConfig($controllerExtensionName, $form, $contentType);
$this->addIcon($form, $contentType);
$this->addPageTsConfig($form, $contentType);
}

/**
* @param Form $form
* @param string $contentType
* @return void
* @return string
*/
protected function addIcon(Form $form, $contentType)
{
if (isset($GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$contentType])) {
return $GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$contentType];
}
$icon = MiscellaneousUtility::getIconForTemplate($form);
if (strpos($icon, 'EXT:') === 0 || $icon{0} !== '/') {
$icon = GeneralUtility::getFileAbsFileName($icon);
}
if (!$icon) {
$icon = ExtensionManagementUtility::extPath('flux', 'Resources/Public/Icons/Plugin.png');
}
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$contentType] = MiscellaneousUtility::createIcon(
$iconIdentifier = MiscellaneousUtility::createIcon(
$icon,
Icon::SIZE_DEFAULT,
Icon::SIZE_DEFAULT
);
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$contentType] = $iconIdentifier;
return $iconIdentifier;
}

/**
Expand All @@ -222,26 +226,17 @@ public function addBoilerplateTableConfiguration($contentType)
}

/**
* @param string $providerExtensionName
* @param Form $form
* @param string $contentType
* @return void
*/
protected function addPageTsConfig($providerExtensionName, Form $form, $contentType)
protected function addPageTsConfig(Form $form, $contentType)
{
// Icons required solely for use in the "new content element" wizard
$extensionKey = ExtensionNamingUtility::getExtensionKey($providerExtensionName);
$defaultIcon = ExtensionManagementUtility::extPath($extensionKey, 'ext_icon.gif');

$formId = $form->getId();
$icon = $form->getOption(Form::OPTION_ICON) ?? $defaultIcon;
$group = $form->getOption(Form::OPTION_GROUP) ?? 'fluxContent';
$this->initializeNewContentWizardGroup($this->sanitizeString($group), $group);

$iconIdentifier = $extensionKey . '-' . $formId;
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerIcon($iconIdentifier, BitmapIconProvider::class, ['source' => $icon]);

// Registration for "new content element" wizard to show our new CType (otherwise, only selectable via "Content type" drop-down)
ExtensionManagementUtility::addPageTSConfig(
sprintf(
Expand All @@ -256,7 +251,7 @@ protected function addPageTsConfig($providerExtensionName, Form $form, $contentT
mod.wizards.newContentElement.wizardItems.%s.show := addToList(%s)',
$this->sanitizeString($group),
$formId,
$iconIdentifier,
$this->addIcon($form, $contentType),
$form->getLabel(),
$form->getDescription(),
$contentType,
Expand Down Expand Up @@ -289,7 +284,8 @@ protected function registerExtbasePluginForForm($providerExtensionName, $pluginN
ExtensionUtility::registerPlugin(
$providerExtensionName,
$pluginName,
$form->getLabel()
$form->getLabel(),
MiscellaneousUtility::getIconForTemplate($form)
);
}

Expand Down

0 comments on commit 9d0ab22

Please sign in to comment.