ModuleUpdateRequirementsHooks.php

Namespace

Drupal\module_update_requirements\Hook

File

core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\module_update_requirements\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Hook implementations for module_update_requirements.
 */
class ModuleUpdateRequirementsHooks {
    use StringTranslationTrait;
    
    /**
     * Implements hook_update_requirements().
     */
    public function updateRequirements() : array {
        return [
            'test.update.error' => [
                'title' => $this->t('UpdateError'),
                'value' => $this->t('None'),
                'description' => $this->t('Update Error.'),
                'severity' => REQUIREMENT_ERROR,
            ],
            'test.update.error.alter' => [
                'title' => $this->t('UpdateError'),
                'value' => $this->t('None'),
                'description' => $this->t('Update Error.'),
                'severity' => REQUIREMENT_ERROR,
            ],
        ];
    }
    
    /**
     * Implements hook_update_requirements_alter().
     */
    public function updateRequirementsAlter(array &$requirements) : void {
        $requirements['test.update.error.alter'] = [
            'title' => $this->t('UpdateWarning'),
            'value' => $this->t('None'),
            'description' => $this->t('Update Warning.'),
            'severity' => REQUIREMENT_WARNING,
        ];
    }

}

Classes

Title Deprecated Summary
ModuleUpdateRequirementsHooks Hook implementations for module_update_requirements.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.