The Packages Service
Last updated on
11 April 2017
Packages provides a Packages service which is what should be used to either load Packages or their states.
$packages = \Drupal::service('packages');
If you want to load your Package plugin with the user's settings populated, you would:
$package = $packages->getPackage('my_package_id');
To determine if your package is active which means that the user has enabled the package and has access to it (in the event that the package requires an additional permission):
$packages->getState('my_package_id')->isActive();
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion