Skip to main content

GravityKit\GravityMigrate\Abilities\Refusal

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

The decision lives in \Permission and \ExternalMigration; only the sentence is here. The opposite number is \GravityKit\GravityMigrate\CLI\MigrationRefusal, which words the same refusals for a terminal -- an instruction to re-run with --user is not actionable by a client with no login to re-run as, so a refusal here names the tool that answers the question instead.

Depends on nothing beyond WP_Error, so every reason can be held to having wording.

Since: %ver%

Source: src/Abilities/Refusal.php:29

Details

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

Methods

MethodDescription
capability_wording()What an ability says when a capability is missing, and the error code it says it under.
for_capability()A capability refusal as an error, or true when nothing was refused.
advice()What an agent can do about an error the shared layer returned.
for_error()One error with this surface's next step added to it, and an HTTP status attached.

Method Reference

capability_wording()

public static function capability_wording(): array

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

Keyed by \Permission's reasons. A reason with no entry reaches the caller as a blank refusal.

Returns

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

Since: %ver%

Source: src/Abilities/Refusal.php:51

for_capability()

public static function for_capability( string $reason )

A capability refusal as an error, or true when nothing was refused.

Parameters

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

Returns

Since: %ver%

Source: src/Abilities/Refusal.php:69

advice()

public static function advice(): array

What an agent can do about an error the shared layer returned.

Appended to the error's own message, which states the condition; only the next step is this surface's to name, and it names a tool so the agent has something to call.

Returns

  • array<string, — string>

Since: %ver%

Source: src/Abilities/Refusal.php:93

for_error()

public static function for_error( WP_Error $error ): WP_Error

One error with this surface's next step added to it, and an HTTP status attached.

422 rather than 400: the input parsed, and what it named does not exist or cannot be used. An error that already carries a status keeps it.

Parameters

NameTypeDefaultDescription
$errorWP_ErrorThe error the shared layer returned.

Returns

Since: %ver%

Source: src/Abilities/Refusal.php:162