Source of file CD_getFileInline_Extension.php
Size: 0,850 Bytes - Last Modified: 2021-12-24T06:40:30+00:00
/var/www/docs.ssmods.com/process/src/code/CD_getFileInline_Extension.php
12345678910111213141516171819202122232425262728293031323334353637383940 | <?php namespace ChristopherDarling\TemplateInlineFile; use SilverStripe\Control\Director; use SilverStripe\View\TemplateGlobalProvider; class TemplateInlineFile implements TemplateGlobalProvider { public static function get_template_global_variables() { return [ 'TemplateInlineFile' => [ 'method' => 'getPath', 'casting' => 'HTMLFragment' ] ]; } /** * @param mixed ...$paths * @return false|string|void */ public static function getPath(...$paths) { $path = implode('', $paths); $absPath = Director::getAbsFile($path); if (!file_exists($absPath)) { user_error('TemplateInlineFile $path (' . $absPath .') does not exist'); return; } return file_get_contents($absPath); } } |