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