-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Improve typing to support refactored template layer #647
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
Comment on lines
-1325
to
1333
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just adding a bit of type safety since this method gets used in |
||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,9 @@ | |
use SilverStripe\View\HTML; | ||
use SilverStripe\View\Parsers\ShortcodeHandler; | ||
use SilverStripe\View\Parsers\ShortcodeParser; | ||
use SilverStripe\View\SSTemplateEngine; | ||
use SilverStripe\View\SSViewer; | ||
use SilverStripe\View\SSViewer_FromString; | ||
use SilverStripe\View\ViewLayerData; | ||
|
||
/** | ||
* Provides shortcodes for File dataobject | ||
|
@@ -237,9 +238,9 @@ protected static function find_error_record($errorCode) | |
*/ | ||
public static function getCacheKey($params, $content = null) | ||
{ | ||
$key = SSViewer::config()->get('global_key'); | ||
$viewer = new SSViewer_FromString($key); | ||
$globalKey = md5($viewer->process(ArrayData::create([])) ?? ''); | ||
$key = SSTemplateEngine::config()->get('global_key'); | ||
$engine = SSTemplateEngine::create(); | ||
$globalKey = md5($engine->renderString($key, ViewLayerData::create([]))); | ||
Comment on lines
+241
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly use |
||
$argsKey = md5(serialize($params)) . '#' . md5(serialize($content)); | ||
|
||
return "{$globalKey}#{$argsKey}"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbObject()
can returnnull