static function FTP::factory in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/FileTransfer/FTP.php \Drupal\Core\FileTransfer\FTP::factory()
Defines a factory method for this class.
Classes that extend this class must override the factory() static method. They should return a new instance of the appropriate FileTransfer subclass.
Parameters
string $jail: The full path where all file operations performed by this object will be restricted to. This prevents the FileTransfer classes from being able to touch other parts of the filesystem.
array $settings: An array of connection settings for the FileTransfer subclass. If the getSettingsForm() method uses any nested settings, the same structure will be assumed here.
Return value
object New instance of the appropriate FileTransfer subclass.
Throws
\Drupal\Core\FileTransfer\FileTransferException
Overrides FileTransfer::factory
File
- core/
lib/ Drupal/ Core/ FileTransfer/ FTP.php, line 29 - Contains \Drupal\Core\FileTransfer\FTP.
Class
- FTP
- Defines the base class for FTP implementations.
Namespace
Drupal\Core\FileTransferCode
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);
}