X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fservice%2Funinstall-validator.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fservice%2Funinstall-validator.twig;h=ebceaca168a6c2ae6ac91b39e0bb4570cad82eb0;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/service/uninstall-validator.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/service/uninstall-validator.twig new file mode 100644 index 000000000..ebceaca16 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d8/service/uninstall-validator.twig @@ -0,0 +1,70 @@ +blockManager = $block_manager; + $this->blockStorage = $entity_manager->getStorage('block'); + $this->stringTranslation = $string_translation; + } + + /** + * {@inheritdoc} + */ + public function validate($module) { + $reasons = []; + + foreach ($this->blockStorage->loadMultiple() as $block) { + /** @var \Drupal\block\BlockInterface $block */ + $definition = $block->getPlugin() + ->getPluginDefinition(); + if ($definition['provider'] == $module) { + $message_arguments = [ + ':url' => $block->toUrl('edit-form')->toString(), + '@block_id' => $block->id(), + ]; + $reasons[] = $this->t('Provides a block plugin that is in use in the following block: @block_id', $message_arguments); + } + } + + return $reasons; + } + +}