Local
class Local extends FileTransfer implements ChmodInterface (View source)
Defines the local connection class for copying files as the httpd user.
Traits
Provides dependency injection friendly methods for serialization.
Properties
| protected string | $username | The username for this file transfer. |
from FileTransfer |
| protected string | $password | The password for this file transfer. |
from FileTransfer |
| protected string | $hostname | The hostname for this file transfer. |
from FileTransfer |
| protected int | $port | The port for this file transfer. |
from FileTransfer |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected FileSystemInterface | $fileSystem | The file system service. |
Methods
Constructs a Drupal\Core\FileTransfer\FileTransfer object.
Defines a factory method for this class.
Connects to the server.
Changes the permissions of the specified $path (file or directory).
Checks that the path is inside the jail and throws an exception if not.
Returns a modified path suitable for passing to the server.
Changes backslashes to slashes, also removes a trailing slash.
Creates a directory.
Removes a directory.
Copies a file.
Removes a file.
Checks if a particular path is a directory.
Checks if a particular path is a file (not a directory).
Sets the chroot and changes the jail to match the correct path scheme.
Returns a form to collect connection settings credentials.
Changes the permissions of the file / directory specified in $path.
Details
__construct($jail, FileSystemInterface $file_system)
Constructs a Drupal\Core\FileTransfer\FileTransfer object.
static object
factory(string $jail, array $settings)
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.
string|bool
__get(string $name)
Implements the magic __get() method.
If the connection isn't set to anything, this will call the connect() method and return the result; afterwards, the connection will be returned directly without using this method.
connect()
Connects to the server.
final
copyDirectory(string $source, string $destination)
Copies a directory.
final
chmod(string $path, int $mode, bool $recursive = FALSE)
Changes the permissions of the specified $path (file or directory).
final
createDirectory(string $directory)
Creates a directory.
final
removeDirectory(string $directory)
Removes a directory.
final
copyFile(string $source, string $destination)
Copies a file.
final
removeFile(string $destination)
Removes a file.
final protected
checkPath(string $path)
Checks that the path is inside the jail and throws an exception if not.
final protected string
fixRemotePath(string $path, bool $strip_chroot = TRUE)
Returns a modified path suitable for passing to the server.
If a path is a windows path, makes it POSIX compliant by removing the drive letter. If $this->chroot has a value and $strip_chroot is TRUE, it is stripped from the path to allow for chroot'd filetransfer systems.
string
sanitizePath(string $path)
Changes backslashes to slashes, also removes a trailing slash.
protected
copyDirectoryJailed(string $source, string $destination)
Copies a directory.
We need a separate method to make sure the $destination is in the jail.
protected
createDirectoryJailed(string $directory)
Creates a directory.
protected
removeDirectoryJailed(string $directory)
Removes a directory.
protected
copyFileJailed(string $source, string $destination)
Copies a file.
protected
removeFileJailed($file)
Removes a file.
bool
isDirectory(string $path)
Checks if a particular path is a directory.
bool
isFile(string $path)
Checks if a particular path is a file (not a directory).
string|bool
findChroot()
Returns the chroot property for this connection.
It does this by moving up the tree until it finds itself
setChroot()
Sets the chroot and changes the jail to match the correct path scheme.
array
getSettingsForm()
Returns a form to collect connection settings credentials.
Implementing classes can either extend this form with fields collecting the specific information they need, or override it entirely.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
chmodJailed(string $path, int $mode, bool $recursive)
Changes the permissions of the file / directory specified in $path.