You are here

public function Ftp::ensure in Flysystem 8

Same name and namespace in other branches
  1. 7 src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp::ensure()
  2. 3.x src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp::ensure()
  3. 2.0.x src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp::ensure()
  4. 3.0.x src/Flysystem/Ftp.php \Drupal\flysystem\Flysystem\Ftp::ensure()

Checks the sanity of the filesystem.

If this is a local filesystem, .htaccess file should be in place.

Return value

array A list of error messages.

Overrides FlysystemPluginInterface::ensure

File

src/Flysystem/Ftp.php, line 64

Class

Ftp
Drupal plugin for the "FTP" Flysystem adapter.

Namespace

Drupal\flysystem\Flysystem

Code

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' => isset($this->configuration['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' => isset($this->configuration['port']) ? $this->configuration['port'] : 21,
      ],
    ],
  ];
}