BootstrapLayoutsUninstallValidator.php in Bootstrap Layouts 8.5
File
src/BootstrapLayoutsUninstallValidator.php
View source
<?php
namespace Drupal\bootstrap_layouts;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class BootstrapLayoutsUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
protected $manager;
public function __construct(BootstrapLayoutsManager $manager) {
$this->manager = $manager;
}
public function validate($module) {
$reasons = [];
if ($module === 'bootstrap_layouts') {
$layouts = [];
foreach ($this->manager
->getHandlers() as $handler) {
foreach ($handler
->loadInstances() as $storage_id => $layout) {
if ($layout
->isBootstrapLayout()) {
$layouts[$layout
->getId()][] = $handler
->getPluginId() . ':' . $storage_id;
}
}
}
ksort($layouts);
foreach ($layouts as $layout_id => $storage_ids) {
sort($storage_ids, SORT_NATURAL);
$reasons[] = $this
->t('Using layout: @layout_id (@storage_ids)', [
'@layout_id' => $layout_id,
'@storage_ids' => implode(', ', $storage_ids),
]);
}
}
return $reasons;
}
}