FTP.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/FileTransfer/FTP.php
  2. 8.9.x core/lib/Drupal/Core/FileTransfer/FTP.php
  3. 10 core/lib/Drupal/Core/FileTransfer/FTP.php

Namespace

Drupal\Core\FileTransfer

File

core/lib/Drupal/Core/FileTransfer/FTP.php

View source
<?php

namespace Drupal\Core\FileTransfer;


/**
 * Defines the base class for FTP implementations.
 *
 * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no
 *   replacement. Use composer to manage the code for your site.
 *
 * @see https://www.drupal.org/node/3512364
 */
abstract class FTP extends FileTransfer {
    
    /**
     * {@inheritdoc}
     */
    public function __construct($jail, $username, $password, $hostname, $port) {
        @trigger_error(__CLASS__ . ' is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
        $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;
    }

}

Classes

Title Deprecated Summary
FTP

in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site.

Defines the base class for FTP implementations.

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