Translate the file ID to file path.
public static convertValueToPath ( string $varValue ) : string | ||
$varValue | string | The file id. |
Résultat | string |
/** * Get a 16x16 pixel resized icon of the passed image if it exists, return the default icon otherwise. * * @param string $icon The icon to resize. * * @param string $defaultIcon The default icon. * * @return string */ public function getBackendIcon($icon, $defaultIcon = 'system/modules/metamodels/assets/images/icons/metamodels.png') { $dispatcher = $this->getDispatcher(); $realIcon = ToolboxFile::convertValueToPath($icon); // Determine image to use. if ($realIcon && file_exists(TL_ROOT . '/' . $realIcon)) { $event = new ResizeImageEvent($realIcon, 16, 16); $dispatcher->dispatch(ContaoEvents::IMAGE_RESIZE, $event); return $event->getResultImage(); } return $defaultIcon; }
/** * Test whether the given image exists. * * @param string $uuidImage The uuid of the image. * @param string $strDefault Path to the fallback image. * * @return string If the image exists, the image is returned, the default otherwise. */ protected function ensureImage($uuidImage, $strDefault) { $imagePath = ToolboxFile::convertValueToPath($uuidImage); if (strlen($imagePath) && file_exists(TL_ROOT . '/' . $imagePath)) { return $imagePath; } return $strDefault; }
/** * Handle stand alone integration in the backend. * * @param IInputScreen $inputScreen The input screen containing the information. * * @return void */ private function addModuleToBackendMenu($inputScreen) { $metaModel = $inputScreen->getMetaModel(); $moduleName = 'metamodel_' . $metaModel->getTableName(); $tableCaption = $metaModel->getName(); $icon = $this->buildIcon(ToolboxFile::convertValueToPath($inputScreen->getIcon())); $section = $inputScreen->getBackendSection(); if (!$section) { $section = 'metamodels'; } $this->backendMenu[$section][$moduleName] = array('tables' => array($metaModel->getTableName()), 'icon' => $icon, 'callback' => 'MetaModels\\BackendIntegration\\Module'); $caption = array($tableCaption); foreach ($inputScreen->getBackendCaption() as $languageEntry) { if ($languageEntry['langcode'] == 'en') { $caption = array($languageEntry['label'], $languageEntry['description']); } if (!empty($languageEntry['label']) && $languageEntry['langcode'] == $this->viewCombinations->getUser()->language) { $caption = array($languageEntry['label'], $languageEntry['description']); break; } } $this->languageStrings['MOD'][$moduleName] = $caption; }
/** * Generate a 16x16 pixel version of the passed image file. If this can not be done, the default image is returned. * * @param string $icon The name of the image file. * * @return null|string */ public function getBackendIcon($icon) { // Determine the image to use. if ($icon) { $icon = ToolboxFile::convertValueToPath($icon); /** @var ResizeImageEvent $event */ $event = $this->serviceContainer->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_RESIZE, new ResizeImageEvent($icon, 16, 16)); if (file_exists(TL_ROOT . '/' . $event->getResultImage())) { return $event->getResultImage(); } } return 'system/modules/metamodels/assets/images/icons/metamodels.png'; }