Commit 44097522 authored by webchick's avatar webchick

Issue #2510310 by cilefen, jeroenbegyn, borisson_, er.pushpinderrana,...

Issue #2510310 by cilefen, jeroenbegyn, borisson_, er.pushpinderrana, jhodgdon, stefan.r, alexpott: Improve hook_system_info_alter documentation to mention ModuleUninstallValidatorInterface
parent a41cddd9
......@@ -9,12 +9,30 @@
/**
* Common interface for module uninstall validators.
*
* A module uninstall validator must implement this interface and be defined in
* a Drupal @link container service @endlink that is tagged
* module_install.uninstall_validator.
*/
interface ModuleUninstallValidatorInterface {
/**
* Determines the reasons a module can not be uninstalled.
*
* Example implementation:
* @code
* public function validate($module) {
* $entity_types = $this->entityManager->getDefinitions();
* $reasons = array();
* foreach ($entity_types as $entity_type) {
* if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
* $reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
* }
* }
* return $reasons;
* }
* @endcode
*
* @param string $module
* A module name.
*
......
......@@ -131,13 +131,18 @@ function hook_module_implements_alter(&$implementations, $hook) {
}
/**
* Alter the information parsed from module and theme .info.yml files
* Alter the information parsed from module and theme .info.yml files.
*
* This hook is invoked in _system_rebuild_module_data() and in
* \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). A module
* may implement this hook in order to add to or alter the data generated by
* reading the .info.yml file with \Drupal\Core\Extension\InfoParser.
*
* Using implementations of this hook to make modules required by setting the
* $info['required'] key is discouraged. Doing so will slow down the module
* installation and uninstallation process. Instead, use
* \Drupal\Core\Extension\ModuleUninstallValidatorInterface.
*
* @param array $info
* The .info.yml file contents, passed by reference so that it can be altered.
* @param \Drupal\Core\Extension\Extension $file
......@@ -145,6 +150,8 @@ function hook_module_implements_alter(&$implementations, $hook) {
* @param string $type
* Either 'module' or 'theme', depending on the type of .info.yml file that
* was passed.
*
* @see \Drupal\Core\Extension\ModuleUninstallValidatorInterface
*/
function hook_system_info_alter(array &$info, \Drupal\Core\Extension\Extension $file, $type) {
// Only fill this in if the .info.yml file does not define a 'datestamp'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment