diff --git a/core/includes/authorize.inc b/core/includes/authorize.inc index 70fb4ca..e582e9c 100644 --- a/core/includes/authorize.inc +++ b/core/includes/authorize.inc @@ -315,7 +315,7 @@ function authorize_get_filetransfer($backend, $settings = array()) { if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) { $backend_info = $_SESSION['authorize_filetransfer_info'][$backend]; if (class_exists($backend_info['class'])) { - $filetransfer = $backend_info['class']::factory(DRUPAL_ROOT, $settings); + $filetransfer = $backend_info['class']::create(DRUPAL_ROOT, $settings); } } return $filetransfer; diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransferBase.php b/core/lib/Drupal/Core/FileTransfer/FileTransferBase.php index 095f0f1..2901e26 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransferBase.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransferBase.php @@ -61,7 +61,7 @@ function __construct($jail) { /** * Defines a factory method for this class. * - * Classes that extend this class must override the factory() static method. + * Classes that extend this class must override the create() static method. * They should return a new instance of the appropriate FileTransfer subclass. * * @param string $jail @@ -78,8 +78,8 @@ function __construct($jail) { * * @throws \Drupal\Core\FileTransfer\FileTransferException */ - static function factory($jail, $settings) { - throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.'); + static function create($jail, $settings) { + throw new FileTransferException('FileTransfer::create() static method not overridden by FileTransfer subclass.'); } /** diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransferManager.php b/core/lib/Drupal/Core/FileTransfer/FileTransferManager.php index f9afac6..2094780 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransferManager.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransferManager.php @@ -37,7 +37,7 @@ class FileTransferManager extends DefaultPluginManager { * The module handler. */ public function __construct(\Traversable $namespaces, ModuleHandlerInterface $module_handler) { - parent::__construct('FileTransfer', $namespaces, array(), 'Drupal\Core\Annotation\FileTransfer'); + parent::__construct('Plugin\FileTransfer', $namespaces, 'Drupal\Core\Annotation\FileTransfer'); $this->alterInfo($module_handler, 'filetransfer_info'); } diff --git a/core/lib/Drupal/Core/FileTransfer/Ftp.php b/core/lib/Drupal/Core/FileTransfer/Ftp.php index 443e523..349c38f 100644 --- a/core/lib/Drupal/Core/FileTransfer/Ftp.php +++ b/core/lib/Drupal/Core/FileTransfer/Ftp.php @@ -13,7 +13,7 @@ abstract class Ftp extends FileTransferBase { /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::__construct(). + * @{inheritdoc} */ public function __construct($jail, $username, $password, $hostname, $port) { $this->username = $username; @@ -24,9 +24,9 @@ public function __construct($jail, $username, $password, $hostname, $port) { } /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::factory(). + * @{inheritdoc} */ - static function factory($jail, $settings) { + static function create($jail, $settings) { $username = empty($settings['username']) ? '' : $settings['username']; $password = empty($settings['password']) ? '' : $settings['password']; $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname']; @@ -43,7 +43,7 @@ static function factory($jail, $settings) { } /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::getSettingsForm(). + * @{inheritdoc} */ public function getSettingsForm() { $form = parent::getSettingsForm(); diff --git a/core/lib/Drupal/Core/FileTransfer/Plugin/FileTransfer/Ssh.php b/core/lib/Drupal/Core/FileTransfer/Plugin/FileTransfer/Ssh.php index cbb35f5..bc71528 100644 --- a/core/lib/Drupal/Core/FileTransfer/Plugin/FileTransfer/Ssh.php +++ b/core/lib/Drupal/Core/FileTransfer/Plugin/FileTransfer/Ssh.php @@ -10,8 +10,6 @@ use Drupal\Core\FileTransfer\FileTransferException; use Drupal\Core\FileTransfer\FileTransferBase; use Drupal\Core\FileTransfer\ChmodInterface; -use Drupal\Core\Annotation\FileTransfer; -use Drupal\Core\Annotation\Translation; /** * The SSH connection class for the update module. @@ -25,7 +23,7 @@ class Ssh extends FileTransferBase implements ChmodInterface { /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::__construct(). + * @{inheritdoc} */ function __construct($jail, $username, $password, $hostname = "localhost", $port = 22) { $this->username = $username; @@ -36,7 +34,7 @@ function __construct($jail, $username, $password, $hostname = "localhost", $port } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::connect(). + * @{inheritdoc} */ function connect() { $this->connection = @ssh2_connect($this->hostname, $this->port); @@ -49,9 +47,9 @@ function connect() { } /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::factory(). + * @{inheritdoc} */ - static function factory($jail, $settings) { + static function create($jail, $settings) { $username = empty($settings['username']) ? '' : $settings['username']; $password = empty($settings['password']) ? '' : $settings['password']; $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname']; @@ -60,7 +58,7 @@ static function factory($jail, $settings) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::copyFileJailed(). + * @{inheritdoc} */ protected function copyFileJailed($source, $destination) { if (!@ssh2_scp_send($this->connection, $source, $destination)) { @@ -69,7 +67,7 @@ protected function copyFileJailed($source, $destination) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::copyDirectoryJailed(). + * @{inheritdoc} */ protected function copyDirectoryJailed($source, $destination) { if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) { @@ -78,7 +76,7 @@ protected function copyDirectoryJailed($source, $destination) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::createDirectoryJailed(). + * @{inheritdoc} */ protected function createDirectoryJailed($directory) { if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) { @@ -87,7 +85,7 @@ protected function createDirectoryJailed($directory) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::removeDirectoryJailed(). + * @{inheritdoc} */ protected function removeDirectoryJailed($directory) { if (@!ssh2_exec($this->connection, 'rm -Rf ' . escapeshellarg($directory))) { @@ -96,7 +94,7 @@ protected function removeDirectoryJailed($directory) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::removeFileJailed(). + * @{inheritdoc} */ protected function removeFileJailed($destination) { if (!@ssh2_exec($this->connection, 'rm ' . escapeshellarg($destination))) { @@ -125,7 +123,7 @@ public function isDirectory($path) { } /** - * Implements Drupal\Core\FileTransfer\FileTransfer::isFile(). + * @{inheritdoc} */ public function isFile($path) { $file = escapeshellarg($path); @@ -142,7 +140,7 @@ public function isFile($path) { } /** - * Implements Drupal\Core\FileTransfer\ChmodInterface::chmodJailed(). + * @{inheritdoc} */ function chmodJailed($path, $mode, $recursive) { $cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path)); @@ -152,7 +150,7 @@ function chmodJailed($path, $mode, $recursive) { } /** - * Overrides Drupal\Core\FileTransfer\FileTransfer::getSettingsForm(). + * @{inheritdoc} */ public function getSettingsForm() { $form = parent::getSettingsForm(); diff --git a/core/modules/system/lib/Drupal/system/Tests/FileTransfer/TestFileTransfer.php b/core/modules/system/lib/Drupal/system/Tests/FileTransfer/TestFileTransfer.php index ec885db..2055b98 100644 --- a/core/modules/system/lib/Drupal/system/Tests/FileTransfer/TestFileTransfer.php +++ b/core/modules/system/lib/Drupal/system/Tests/FileTransfer/TestFileTransfer.php @@ -24,45 +24,75 @@ class TestFileTransfer extends FileTransferBase { */ public $shouldIsDirectoryReturnTrue = FALSE; + /** + * @(inheritdoc) + */ function __construct($jail, $username, $password, $hostname = 'localhost', $port = 9999) { parent::__construct($jail, $username, $password, $hostname, $port); } - static function factory($jail, $settings) { + /** + * @(inheritdoc) + */ + static function create($jail, $settings) { return new TestFileTransfer($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']); } + /** + * @(inheritdoc) + */ function connect() { $this->connection = new MockTestConnection(); $this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@$this->host:$this->port/"; } + /** + * @(inheritdoc) + */ function copyFileJailed($source, $destination) { $this->connection->run("copyFile $source $destination"); } + /** + * @(inheritdoc) + */ protected function removeDirectoryJailed($directory) { $this->connection->run("rmdir $directory"); } + /** + * @(inheritdoc) + */ function createDirectoryJailed($directory) { $this->connection->run("mkdir $directory"); } + /** + * @(inheritdoc) + */ function removeFileJailed($destination) { if (!ftp_delete($this->connection, $item)) { throw new FileTransferException('Unable to remove to file @file.', NULL, array('@file' => $item)); } } + /** + * @(inheritdoc) + */ function isDirectory($path) { return $this->shouldIsDirectoryReturnTrue; } + /** + * @(inheritdoc) + */ function isFile($path) { return FALSE; } + /** + * @(inheritdoc) + */ function chmodJailed($path, $mode, $recursive) { return; }