You are here

class ActionQuickUpload in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

Hierarchy

  • class \Drupal\n1ed\Flmngr\FileUploaderServer\lib\action\AAction

Expanded class hierarchy of ActionQuickUpload

1 file declares its use of ActionQuickUpload
Actions.php in src/Flmngr/FileUploaderServer/lib/Actions.php

File

src/Flmngr/FileUploaderServer/lib/action/ActionQuickUpload.php, line 18

Namespace

Drupal\n1ed\Flmngr\FileUploaderServer\lib\action
View source
class ActionQuickUpload extends AActionUploadId {
  public function getName() {
    return 'upload';
  }
  public function run($req) {
    $fileSystem = new FMDiskFileSystem([
      'dirFiles' => $this->config
        ->getBaseDir(),
      'dirCache' => '',
    ]);
    if ($req->file) {
      if (array_key_exists('dir', $_POST) && $_POST['dir'] && $_POST['dir'] != '/' && $_POST['dir'] != '' && $_POST['dir'] != '.') {
        $target_dir = basename($_POST['dir']);
        $path = dirname($_POST['dir']) == '.' || dirname($_POST['dir']) == '/' ? '' : '/' . dirname($_POST['dir']);
        $fullPath = basename($this->m_config
          ->getBaseDir()) . $path;
        $fileSystem
          ->createDir($fullPath, $target_dir);
        $uploadDir = $fileSystem
          ->getAbsolutePath($fullPath) . '/' . $target_dir;
        $req->m_relativePath = $_POST['dir'];
      }
      else {
        $target_dir = '';
        $fullPath = basename($this->config
          ->getBaseDir());
        $uploadDir = $fileSystem
          ->getAbsolutePath($fullPath) . '/' . $target_dir . '/';
        $req->relativePath = '/';
      }
      $file = new FileUploadedQuick($this->config, $uploadDir, $req->fileName, $req->fileName, $req->relativePath);
      $file
        ->upload($req->file);
      $resp = new RespUploadAddFile();
      $resp->file = $file
        ->getData();
      return $resp;
    }
    else {
      throw new MessageException(Message::createMessage(Message::FILES_NOT_SET));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AAction::$config protected property
AAction::setConfig public function Sets a config.
AAction::validateBoolean protected function Validates boolean and returns default value if null.
AAction::validateInteger protected function Validates integer and returns default value if null.
AAction::validateString protected function Validates string and returns default value if null.
AActionUploadId::validateUploadId protected function Validates upload ID and throws exception in case of validation error.
ActionQuickUpload::getName public function Returnes name of action. Overrides AAction::getName
ActionQuickUpload::run public function Runs action. Overrides AAction::run