MetaModels\Helper\ToolboxFile::convertValueToPath PHP Méthode

convertValueToPath() public static méthode

Translate the file ID to file path.
public static convertValueToPath ( string $varValue ) : string
$varValue string The file id.
Résultat string
    public static function convertValueToPath($varValue)
    {
        $objFiles = \FilesModel::findByPk($varValue);
        if ($objFiles !== null) {
            return $objFiles->path;
        }
        return '';
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of MetaModels\Helper\ToolboxFile::convertValueToPath