class FTP

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/FileTransfer/FTP.php \Drupal\Core\FileTransfer\FTP
  2. 10 core/lib/Drupal/Core/FileTransfer/FTP.php \Drupal\Core\FileTransfer\FTP
  3. 8.9.x core/lib/Drupal/Core/FileTransfer/FTP.php \Drupal\Core\FileTransfer\FTP

Defines the base class for FTP implementations.

Hierarchy

Expanded class hierarchy of FTP

7 string references to 'FTP'
core.services.yml in core/core.services.yml
core/core.services.yml
default.services.yml in sites/default/default.services.yml
sites/default/default.services.yml
default.services.yml in core/assets/scaffold/files/default.services.yml
core/assets/scaffold/files/default.services.yml
system_filetransfer_info in core/modules/system/system.module
Implements hook_filetransfer_info().
update_manager_file_get in core/modules/update/update.manager.inc
Copies a file from the specified URL to the temporary directory for updates.

... See full list

File

core/lib/Drupal/Core/FileTransfer/FTP.php, line 8

Namespace

Drupal\Core\FileTransfer
View source
abstract class FTP extends FileTransfer {
  
  /**
   * {@inheritdoc}
   */
  public function __construct($jail, $username, $password, $hostname, $port) {
    $this->username = $username;
    $this->password = $password;
    $this->hostname = $hostname;
    $this->port = $port;
    parent::__construct($jail);
  }
  
  /**
   * {@inheritdoc}
   */
  public static function factory($jail, $settings) {
    $username = empty($settings['username']) ? '' : $settings['username'];
    $password = empty($settings['password']) ? '' : $settings['password'];
    $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
    $port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
    if (function_exists('ftp_connect')) {
      $class = 'Drupal\\Core\\FileTransfer\\FTPExtension';
    }
    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;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.