You are here

public function ImceFM::run in IMCE 8.2

Same name and namespace in other branches
  1. 8 src/ImceFM.php \Drupal\imce\ImceFM::run()

Runs an operation on the file manager.

1 call to ImceFM::run()
ImceFM::pageResponse in src/ImceFM.php
Returns a page response based on the current request.

File

src/ImceFM.php, line 203

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function run($op = NULL) {
  if (!$this->validated) {
    return FALSE;
  }

  // Check operation.
  if (!isset($op)) {
    $op = $this
      ->getOp();
  }
  if (!$op || !is_string($op)) {
    return FALSE;
  }

  // Validate security token.
  $token = $this
    ->getPost('token');
  if (!$token || $token !== $this
    ->getConf('token')) {
    $this
      ->setMessage($this
      ->t('Invalid security token.'));
    return FALSE;
  }

  // Let plugins handle the operation.
  $return = \Drupal::service('plugin.manager.imce.plugin')
    ->handleOperation($op, $this);
  if ($return === FALSE) {
    $this
      ->setMessage($this
      ->t('Invalid operation %op.', [
      '%op' => $op,
    ]));
  }
  return $return;
}