Skip to content

Commit

Permalink
ENH Improve typing to support refactored template layer
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 7, 2024
1 parent df82059 commit 869ab9e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AssetControlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function findAssets(DataObject $record)
}

// Omit variant and merge with set
$next = $record->dbObject($field)->getValue();
$next = $record->dbObject($field)?->getValue();
unset($next['Variant']);
if ($next) {
$files[] = $next;
Expand Down
6 changes: 2 additions & 4 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1322,16 +1322,14 @@ public function forTemplate(): string

/**
* Return a html5 tag of the appropriate for this file (normally img or a)
*
* @return string
*/
public function getTag()
public function getTag(): string
{
$template = $this->File->getFrontendTemplate();
if (empty($template)) {
return '';
}
return (string)$this->renderWith($template);
return $this->renderWith($template);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/php/ImageManipulationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use SilverStripe\Dev\SapphireTest;
use SilverStripe\View\SSViewer;
use PHPUnit\Framework\Attributes\DataProvider;
use SilverStripe\View\SSViewer_FromString;

/**
* ImageTest is abstract and should be overridden with manipulator-specific subtests
Expand Down Expand Up @@ -450,7 +451,7 @@ public function testRender(string $template, string $expected)

$this->assertEquals(
$expected,
trim($image->renderWith(SSViewer::fromString($template)) ?? '')
trim($image->renderWith(SSViewer_FromString::create($template)) ?? '')
);
}

Expand Down

0 comments on commit 869ab9e

Please sign in to comment.