mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FEATURE Option placeholder for upload folder id (#9262)
* FEATURE Option placeholder for upload folder id * ENHANCEMENT Add setFolderName() to TinyMCEConfig * Typehint return type * Add type to param
This commit is contained in:
parent
e585e1e859
commit
58c080db5a
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Forms\HTMLEditor;
|
||||
|
||||
use Exception;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\Module;
|
||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
@ -268,6 +268,7 @@ class TinyMCEConfig extends HTMLEditorConfig
|
||||
'menubar' => false,
|
||||
'language' => 'en',
|
||||
'branding' => false,
|
||||
'upload_folder_id' => null, // Set folder ID for insert media dialog
|
||||
];
|
||||
|
||||
/**
|
||||
@ -844,4 +845,19 @@ class TinyMCEConfig extends HTMLEditorConfig
|
||||
Deprecation::notice('5.0', 'Set base_dir or editor_css config instead');
|
||||
return ModuleLoader::getModule('silverstripe/admin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the upload folder name used by the insert media dialog
|
||||
*
|
||||
* @param string $folderName
|
||||
* @return $this
|
||||
*/
|
||||
public function setFolderName(string $folderName): self
|
||||
{
|
||||
$folder = Folder::find_or_make($folderName);
|
||||
$folderID = $folder ? $folder->ID : null;
|
||||
$this->setOption('upload_folder_id', $folderID);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user