Skip to main content

GravityKit\GravityMigrate\CLI\MigrationRefusal

The terminal's wording for a refusal the shared layer decided.

A migration is refused for reasons every surface shares -- this user may not create forms, that plugin is not installed, no form was named -- and each surface then has to say so in its own terms. "Run with --user=<a login that can>" is the right sentence in a terminal and nonsense from an ability, so the sentence lives here and the decision lives in \Permission and \ExternalMigration.

Two kinds of wording, because refusals arrive in two shapes: a capability reason (\Permission::REASONS()), which is the whole message, and a WP_Error whose message is already fit to print and only wants the terminal's next step added to it.

Holds no WP_CLI, so the unit suite can hold every reason to having wording.

Since: %ver%

Source: src/CLI/MigrationRefusal.php:30

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\CLI

Methods

MethodDescription
capability_wording()What the terminal says when a capability is missing, and the error code it says it under.
for_capability()The whole sentence for a capability refusal, or an empty string when nothing was refused.
advice()What a terminal can do about an error the shared layer returned.
for_error()One error's message with the terminal's next step on the end of it.

Method Reference

capability_wording()

public static function capability_wording(): array

What the terminal says when a capability is missing, and the error code it says it under.

Keyed by \Permission's reasons, and every one of them is here: a reason with no wording reaches an operator as a blank refusal.

Returns

  • array<string, — array{code:string, message:string}>

Since: %ver%

Source: src/CLI/MigrationRefusal.php:42

for_capability()

public static function for_capability( string $reason ): string

The whole sentence for a capability refusal, or an empty string when nothing was refused.

Parameters

NameTypeDefaultDescription
$reasonstring\Permission::ALLOWED() or one of \Permission::REASONS().

Returns

  • string

Since: %ver%

Source: src/CLI/MigrationRefusal.php:72

advice()

public static function advice(): array

What a terminal can do about an error the shared layer returned.

Added after the error's own message rather than replacing it, because the message states the condition -- which slug was not registered, which ids the plugin does have -- and only the next step is the terminal's to name.

Returns

  • array<string, — string>

Since: %ver%

Source: src/CLI/MigrationRefusal.php:89

for_error()

public static function for_error( $error ): string

One error's message with the terminal's next step on the end of it.

Parameters

NameTypeDefaultDescription
$error\WP_ErrorThe error.

Returns

  • string

Since: %ver%

Source: src/CLI/MigrationRefusal.php:105