66use SilverStripe \Assets \Image ;
77use SilverStripe \Control \RequestHandler ;
88use SilverStripe \Core \Extension ;
9+ use SilverStripe \Core \Injector \Injector ;
10+ use SilverStripe \Forager \Extensions \SearchServiceExtension ;
911use SilverStripe \ForagerBifrost \Constants \SearchFile ;
1012use SilverStripe \Forms \FieldList ;
1113use SilverStripe \Forms \Form ;
1214use SilverStripe \Forms \FormFactory ;
1315use SilverStripe \Forms \LiteralField ;
1416use SilverStripe \View \HTML ;
1517
18+
1619class FileFormExtension extends Extension
1720{
1821
@@ -27,6 +30,11 @@ public function updateForm(
2730 string $ name = FormFactory::DEFAULT_NAME ,
2831 array $ context = []
2932 ): void {
33+ $ fileClass = Injector::inst ()->get (File::class);
34+ if (!$ fileClass ->hasExtension (SearchServiceExtension::class)) {
35+ return ;
36+ }
37+
3038 /** @var FieldList $fields */
3139 $ fields = $ form ->Fields ()->fieldByName ('Editor.Details ' );
3240 $ file = $ context ['Record ' ] ?? null ;
@@ -79,7 +87,7 @@ private function createLargeFileWarning(File $file): ?LiteralField
7987 _t (
8088 self ::class . '.LARGE_FILE_WARNING ' ,
8189 'Text contained within this {size} file cannot be indexed for search. '
82- . 'The file size limit for text extraction is {limit}. ' ,
90+ . 'The file size limit for text extraction is {limit}. ' ,
8391 [
8492 'size ' => $ file ->getSize (),
8593 'limit ' => SearchFile::sizeLimit (),
0 commit comments