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?
Good question. Where's the documentation for a relatively simple task like this?
Hey guys you can checkout this link:https://github.com/shahroq/whale_c5_cheat_sheet#create-a-file-folder...
$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);
Viewing 15 lines of 21 lines. View entire code block.