MaestroNonInteractiveExampleTaskUninstallValidator.php in Maestro 8.2
File
modules/examples/maestro_noninteractive_task_plugin_example/src/MaestroNonInteractiveExampleTaskUninstallValidator.php
View source
<?php
namespace Drupal\maestro_noninteractive_task_plugin_example;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\maestro\Engine\MaestroEngine;
class MaestroNonInteractiveExampleTaskUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
}
public function validate($module) {
$reasons = [];
if ($module == 'maestro_noninteractive_task_plugin_example') {
$templates = MaestroEngine::getTemplates();
foreach ($templates as $template) {
foreach ($template->tasks as $task) {
if ($task['tasktype'] == 'MaestroNonIntExample') {
$reasons[] = $this
->t('To uninstall the Non Interactive Plugin Task Example module, remove the Non Interactive Example task from the <em>:template</em> template.', [
':template' => $template->label,
]);
}
}
}
}
return $reasons;
}
}