class Ftp in Flysystem 2.0.x
Same name and namespace in other branches
- 8 src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp
- 7 src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp
- 3.x src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp
- 3.0.x src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp
Drupal plugin for the "FTP" Flysystem adapter.
Plugin annotation
@Adapter(
id = "ftp",
extensions = {"ftp"}
)
Hierarchy
- class \Drupal\flysystem\Flysystem\Ftp implements FlysystemPluginInterface uses FlysystemUrlTrait
Expanded class hierarchy of Ftp
1 file declares its use of Ftp
- FtpTest.php in tests/
src/ Unit/ Flysystem/ FtpTest.php
File
- src/
Flysystem/ Ftp.php, line 19
Namespace
Drupal\flysystem\FlysystemView source
class Ftp implements FlysystemPluginInterface {
use FlysystemUrlTrait;
/**
* Plugin configuration.
*
* @var array
*/
protected $configuration;
/**
* Constructs an Ftp object.
*
* @param array $configuration
* Plugin configuration array.
*/
public function __construct(array $configuration) {
$this->configuration = $configuration;
if (empty($this->configuration['host'])) {
$this->configuration['host'] = '127.0.0.1';
}
}
/**
* {@inheritdoc}
*/
public function getAdapter() {
try {
$adapter = new FtpAdapter($this->configuration);
$adapter
->connect();
} catch (\RuntimeException $e) {
// A problem connecting to the server.
$adapter = new MissingAdapter();
}
return $adapter;
}
/**
* {@inheritdoc}
*/
public function ensure($force = FALSE) {
if ($this
->getAdapter() instanceof FtpAdapter) {
return [
[
'severity' => RfcLogLevel::INFO,
'message' => 'Successfully connected to %host:%port.',
'context' => [
'%host' => $this->configuration['host'],
'%port' => $this->configuration['port'] ?? 21,
],
],
];
}
return [
[
'severity' => RfcLogLevel::ERROR,
'message' => 'There was an error connecting to the FTP server %host:%port.',
'context' => [
'%host' => $this->configuration['host'],
'%port' => $this->configuration['port'] ?? 21,
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlysystemUrlTrait:: |
public | function | Returns a web accessible URL for the resource. | |
FlysystemUrlTrait:: |
protected | function | Returns the scheme from the internal URI. | |
FlysystemUrlTrait:: |
protected | function | Returns the target file path of a URI. | |
Ftp:: |
protected | property | Plugin configuration. | |
Ftp:: |
public | function |
Checks the sanity of the filesystem. Overrides FlysystemPluginInterface:: |
|
Ftp:: |
public | function |
Returns the Flysystem adapter. Overrides FlysystemPluginInterface:: |
|
Ftp:: |
public | function | Constructs an Ftp object. |