Skip to main content

GravityKit\GravityMigrate\Migration\Permission

The capability rule a migration is subject to, stated once.

Every surface asks the same question -- both AJAX controllers, the background batch route and its job driver, the exporters' and importers' own inner gates, and the CLI -- and a rule each of them states for itself is a rule they can come to disagree about.

The rule is manage_options, because a migration reads one form plugin and writes another, and an import can replace settings, license keys and API credentials. No narrower capability speaks for that: a role granted only its own form plugin's rights has no claim on the rest of the site, and a third-party plugin resolves its capabilities from its own settings, so what it admits is that plugin's decision rather than this site's.

The answer is a condition, never a sentence. A refusal comes back as \self::NEEDS_ADMINISTRATOR(), so the wizard can say "You do not have permission to import forms.", a terminal can say "Run with --user=<an administrator login>", and an ability can say something a model can act on -- all from one decision.

Since: %ver%

Source: src/Migration/Permission.php:30

Details​

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

Methods​

MethodDescription
is_administrator()Whether this user may administer the site.
to_migrate()Whether this user may move forms between form plugins.
readable_directions()The directions this user may read, which is what a listing of the form plugins may show.

Method Reference​

is_administrator()​

public static function is_administrator(): bool

Whether this user may administer the site.

Returns​

  • bool

Since: %ver%

Source: src/Migration/Permission.php:68

to_migrate()​

public static function to_migrate(): string

Whether this user may move forms between form plugins.

No direction and no provider, because neither changes the answer. A signature that accepted them would read as though one of them might.

Returns​

  • string — {@see self::ALLOWED}, or one of {@see self::REASONS}.

Since: %ver%

Source: src/Migration/Permission.php:82

readable_directions()​

public static function readable_directions(): array

The directions this user may read, which is what a listing of the form plugins may show.

Returns​

  • string[] — Any of {@see ExternalMigration::DIRECTION_TO} and DIRECTION_FROM, in that order. Empty when this user may read neither.

Since: %ver%

Source: src/Migration/Permission.php:94