Skip to content

Commit

Permalink
DOC Document update to convert API
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jun 4, 2024
1 parent b80a696 commit ce00443
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions en/02_Developer_Guides/14_Files/05_File_Manipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ namespace App\Conversion;
use Intervention\Image\Exception\ImageException;
use SilverStripe\Assets\Conversion\FileConverter;
use SilverStripe\Assets\Conversion\FileConverterException;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Storage\AssetStore;
use SilverStripe\Assets\Storage\DBFile;
Expand All @@ -234,7 +235,7 @@ class ImageFileConverter implements FileConverter
return $supported;
}
public function convert(DBFile $from, string $toExtension, array $options = []): DBFile
public function convert(DBFile|File $from, string $toExtension, array $options = []): DBFile
{
$from = $this->getOwner();
try {
Expand Down Expand Up @@ -349,6 +350,7 @@ namespace App\Conversion;
use SilverStripe\Assets\Conversion\FileConverter;
use SilverStripe\Assets\Conversion\FileConverterException;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Image_Backend;
use SilverStripe\Assets\Storage\AssetStore;
use SilverStripe\Assets\Storage\DBFile;
Expand All @@ -363,7 +365,7 @@ class MyFileConverter implements FileConverter
return $supported;
}
public function convert(DBFile $from, string $toExtension, array $options = []): DBFile
public function convert(DBFile|File $from, string $toExtension, array $options = []): DBFile
{
$fromExtension = $from->getExtension();
if (!$this->supportsConversion($fromExtension, $toExtension, $options)) {
Expand All @@ -374,7 +376,7 @@ class MyFileConverter implements FileConverter
// Handle conversion to PDF
if (strtolower($toExtension) === 'pdf') {
return $file->manipulateExtension(
return $from->manipulateExtension(
$toExtension,
function (AssetStore $store, string $filename, string $hash, string $variant) {
$tmpFilePath = /* some conversion logic goes here */;
Expand Down

0 comments on commit ce00443

Please sign in to comment.