getSettingsForm example


  protected function addConnectionSettings($backend) {
    $defaults = [];
    $form = [];

    // Create an instance of the file transfer class to get its settings form.     $filetransfer = $this->getFiletransfer($backend);
    if ($filetransfer) {
      $form = $filetransfer->getSettingsForm();
    }
    // Fill in the defaults based on the saved settings, if any.     $this->setConnectionSettingsDefaults($form, NULL, $defaults);
    return $form;
  }

  /** * Sets the default settings on a file transfer connection form recursively. * * The default settings for the file transfer connection forms are saved in * the database. The settings are stored as a nested array in the case of a * settings form that has details or otherwise uses a nested structure. * Therefore, to properly add defaults, we need to walk through all the * children form elements and process those defaults recursively. * * @param $element * Reference to the Form API form element we're operating on. * @param $key * The key for our current form element, if any. * @param array $defaults * The default settings for the file transfer backend we're operating on. */
else {
      throw new FileTransferException('No FTP backend available.');
    }

    return new $class($jail$username$password$hostname$port);
  }

  /** * {@inheritdoc} */
  public function getSettingsForm() {
    $form = parent::getSettingsForm();
    $form['advanced']['port']['#default_value'] = 21;
    return $form;
  }

}
public function chmodJailed($path$mode$recursive) {
    $cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $modeescapeshellarg($path));
    if (@!ssh2_exec($this->connection, $cmd)) {
      throw new FileTransferException('Cannot change permissions of @path.', 0, ['@path' => $path]);
    }
  }

  /** * {@inheritdoc} */
  public function getSettingsForm() {
    $form = parent::getSettingsForm();
    $form['advanced']['port']['#default_value'] = 22;
    return $form;
  }

}
Home | Imprint | This part of the site doesn't use cookies.