#[PluginApi]

Attribute on parameters.

use Saij\WpAppFramework\Api\PluginApi;

Injects the public API (#[PublicApi]) of a plugin into a constructor parameter of a service: #[PluginApi('my-plugin')] ?NoteApi $notes = null.

The parameter must be nullable with the default null: it receives null if the plugin is not active. The class is not loaded by the build, so the plugin may be missing; require it as a development dependency for the IDE and static analysis. Resolving the service before plugins_loaded is an error, because not all plugins are loaded then.

Arguments

#[PluginApi(string $plugin)]
ParameterTypeDefaultDescription
pluginstringrequiredSlug of the plugin (its directory name).