On this page
static function FileTransferFTP::factory
static FileTransferFTP::factory($jail, $settings)
Return an object which can implement the FTP protocol.
Parameters
string $jail:
array $settings:
Return value
FileTransferFTP The appropriate FileTransferFTP subclass based on the available options. If the FTP PHP extension is available, use it.
Overrides FileTransfer::factory
File
- includes/filetransfer/ftp.inc, line 25
Class
- FileTransferFTP
- Base class for FTP implementations.
Code
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 = 'FileTransferFTPExtension';
}
else {
throw new FileTransferException('No FTP backend available.');
}
return new $class($jail, $username, $password, $hostname, $port);
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!filetransfer!ftp.inc/function/FileTransferFTP::factory/7.x