static function FileTransferFTP::factory in Drupal 7
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);
}