API / Minn\Ops / FilesystemCredentials

FilesystemCredentials final class

Minn\Ops\FilesystemCredentials · public/minn/src/Minn/Ops/FilesystemCredentials.php · 214 lines

How the site reaches its own files, and the connection it asks for when it cannot write them itself (probes filesystem-credentials and filesystem-credentials-constants).

The method (get_filesystem_method) is FS_METHOD when set; otherwise direct when a file made in the folder (the content folder by default) belongs to the owner of the running script, or when ownership is relaxed and the file could be made at all; otherwise SSH2, the FTP extension or FTP over sockets, whichever this PHP has; filesystem_method has the last word.

The connection (request_filesystem_credentials): request_filesystem_ credentials may answer first; a direct method needs none. The stored connection (ftp_credentials) is the start, each field then taken from its FTP_* constant, else from the form posted with a good _fs_nonce when it is not empty, else as stored; a host's ":port" is split off (kept only when it is a number); the type is ssh under FTP_SSH, ftps under FTP_SSL, else as posted, stored, or ftp. With no error to show, a host, a user and a password (or, over SSH, both key paths) make it complete: it is stored (not autoloaded) without the password, the keys or the port (the port back on the host) and returned. Otherwise the answer is false and the form is printed, as the reference prints it, after the error's notice (the facade's wp_admin_notice).

Constants and properties

privateNONCE = 'filesystem-credentials'
privateCONSTANTS = array ( 'hostname' => 'FTP_HOST', 'username' => 'FTP_USER', 'password' => 'FTP_PASS', 'public_key' => 'FTP_PUBKEY', 'private_key' => 'FTP_PRIKEY', )

Public

staticmethod(array $asked): mixed#

The method the site's files are reached by (get_filesystem_method).

$askedarray{0?: mixed, 1?: mixed, 2?: mixed}the arguments as given: the method's own, the folder, whether ownership is relaxed
staticrequest(array $asked, array $posted): array#

The connection, or false with the form to print (request_filesystem_credentials); an error's notice is the caller's.

$askedarray{0: mixed, 1?: mixed, 2?: mixed, 3?: mixed, 4?: mixed, 5?: mixed}the arguments as given: the form's address, the type, the error, the folder, the extra fields, whether ownership is relaxed
$postedarray<string, mixed>the request's form
@return array{0: mixed, 1: string} the answer, then what is printed

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatecredentials(array $submitted): array#

The connection as stored, its fields from the constants, the form or what was stored, its port split from the host and its type settled.

$submittedarray<string, mixed>
@return array<string, mixed>
privatehost(array $credentials): string#

The host with its port, as stored and shown. @param array<string, mixed> $credentials

$credentialsarray<string, mixed>
privatetypes(): array#

The connection types this PHP can offer. @return array<string, string>

@return array<string, string>
privateownsNewFiles(string $context): ?bool#

Whether a file made in the folder belongs to the running script's owner; null when none can be made there.

privatetransport(): string|false#

The first remote transport this PHP has, or false.

privateform(string $formPost, array $credentials, array $types, array $extraFields, array $posted): string#

The form asking for the connection, character for character as the reference prints it.

$credentialsarray<string, mixed>
$typesarray<mixed>
$extraFieldsarray<mixed>
$postedarray<string, mixed>