Programmatically add folders to File Manager?

Permalink
Is there a relatively simple way to add a "New Folder" to the File Manager programmatically? If not, where in the core code does this functionality take place?

dzimney
 
paulfeakins replied on at Permalink Reply
paulfeakins
Good question. Where's the documentation for a relatively simple task like this?
dimger84 replied on at Permalink Reply
dimger84
linuxoid replied on at Permalink Reply
linuxoid
$group = Group::getByName('Classifieds User');
if (is_object($group)) {
   $file_system = $this->app->make(Filesystem::class);
   $root_folder = $file_system->getRootFolder();
   $folder = FileFolder::getNodeByName('Classifieds Users');
   if (is_object($folder) && $folder instanceof FileFolder) {
      $pk = PermissionKey::getByHandle('add_file');
      $pk->setPermissionObject($folder);
      $pt = $pk->getPermissionAssignmentObject();
      if (is_object($pt)) {
         $pt->clearPermissionAssignment();
         $pa = $pk->getPermissionAccessObject();
         if (is_object($pa)) {
            $pe = GroupEntity::getOrCreate($group);
            $pa->addListItem($pe, false, PermissionKey::ACCESS_TYPE_INCLUDE);