Loading config/install/documentation_generator.enabled_plugins.yml +1 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,4 @@ plugins: - 'taxonomy_vocabulary' - 'user_role' - 'view' - 'enabled_modules' src/Plugin/DocumentationGeneratorChapter/EnabledModules.php 0 → 100644 +104 −0 Original line number Diff line number Diff line <?php namespace Drupal\documentation_generator\Plugin\DocumentationGeneratorChapter; use Drupal\Core\Url; use Drupal\documentation_generator\Plugin\DocumentationGeneratorChapterBase; /** * Enabled Modules Documentation Generator chapter. * * Implements Documentation Generator Chapter plugin for Modules. * * @DocumentationGeneratorChapter( * id = "enabled_modules", * label = @Translation("Modules") * ) */ class EnabledModules extends DocumentationGeneratorChapterBase { /** * {@inheritdoc} */ public function moduleDependencies() { return []; } /** * {@inheritdoc} */ public function pluginElements() { $enabledModules = $this->moduleHandler ->getModuleList(); return $enabledModules; } /** * {@inheritdoc} */ public function elements() { $elements = []; $elements[] = [ 'type' => 'title', 'level' => 1, 'value' => $this->t('Modules')->render(), ]; $url = Url::fromUserInput('/admin/modules')->setAbsolute()->toString(); $elements[] = [ 'type' => 'paragraph', 'level' => 2, 'value' => $this->t('This section provides information about enabled modules : @parameter')->render(), 'parameters' => [ 0 => [ 'type' => 'link', 'text' => $url, 'src' => $url, ], ], ]; $enabledModules = $this->pluginElements(); $this->removeDisabledElements($enabledModules); $info = $this->extensionList->getAllInstalledInfo(); foreach (array_keys($enabledModules) as $module) { $helpUrl = $url = Url::fromUserInput('/admin/help/' . $module)->setAbsolute()->toString(); $description = $info[$module]['description']; $elements[] = [ 'type' => 'title', 'level' => 2, 'value' => $this->moduleHandler->getName($module), ]; $elements[] = [ 'type' => 'paragraph', 'level' => 3, 'value' => $description, ]; $elements[] = [ 'type' => 'paragraph', 'level' => 3, 'value' => $this->t( 'More about @type at : @parameter', [ '@type' => $this->moduleHandler->getName($module), ] )->render(), 'parameters' => [ 0 => [ 'type' => 'link', 'text' => $helpUrl, 'src' => $helpUrl, ], ], ]; } return $elements; } } src/Plugin/DocumentationGeneratorChapterBase.php +15 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Extension\ExtensionList; /** * Base class for Documentation Generator Chapter plugins. Loading Loading @@ -46,6 +47,13 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D */ protected $configFactory; /** * The Module Extension List . * * @var \Drupal\Core\Extension\ExtensionList */ protected $extensionList; /** * The constructor. * Loading @@ -63,6 +71,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D * The module handler. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. * @param \Drupal\Core\Extension\ExtensionList $extensionList * The module extension list. */ public function __construct( array $configuration, Loading @@ -71,7 +81,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D EntityTypeManagerInterface $entityTypeManager, EntityfieldManagerInterface $entityFieldManager, ModuleHandlerInterface $moduleHandler, ConfigFactoryInterface $configFactory ConfigFactoryInterface $configFactory, ExtensionList $extensionList, ) { parent::__construct( $configuration, Loading @@ -83,6 +94,7 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D $this->entityFieldManager = $entityFieldManager; $this->moduleHandler = $moduleHandler; $this->configFactory = $configFactory; $this->extensionList = $extensionList; } /** Loading @@ -101,7 +113,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D $container->get('entity_type.manager'), $container->get('entity_field.manager'), $container->get('module_handler'), $container->get('config.factory') $container->get('config.factory'), $container->get('extension.list.module') ); } Loading src/Plugin/DocumentationGeneratorChapterManager.php +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\documentation_generator\Plugin; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Traversable; /** * Provides the Documentation Generator Chapter plugin manager. Loading @@ -24,7 +23,7 @@ class DocumentationGeneratorChapterManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct( Traversable $namespaces, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler ) { Loading src/Plugin/DocumentationGeneratorRenderManager.php +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\documentation_generator\Plugin; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Traversable; /** * Provides the Documentation Generator Render plugin manager. Loading @@ -24,7 +23,7 @@ class DocumentationGeneratorRenderManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct( Traversable $namespaces, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler ) { Loading Loading
config/install/documentation_generator.enabled_plugins.yml +1 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,4 @@ plugins: - 'taxonomy_vocabulary' - 'user_role' - 'view' - 'enabled_modules'
src/Plugin/DocumentationGeneratorChapter/EnabledModules.php 0 → 100644 +104 −0 Original line number Diff line number Diff line <?php namespace Drupal\documentation_generator\Plugin\DocumentationGeneratorChapter; use Drupal\Core\Url; use Drupal\documentation_generator\Plugin\DocumentationGeneratorChapterBase; /** * Enabled Modules Documentation Generator chapter. * * Implements Documentation Generator Chapter plugin for Modules. * * @DocumentationGeneratorChapter( * id = "enabled_modules", * label = @Translation("Modules") * ) */ class EnabledModules extends DocumentationGeneratorChapterBase { /** * {@inheritdoc} */ public function moduleDependencies() { return []; } /** * {@inheritdoc} */ public function pluginElements() { $enabledModules = $this->moduleHandler ->getModuleList(); return $enabledModules; } /** * {@inheritdoc} */ public function elements() { $elements = []; $elements[] = [ 'type' => 'title', 'level' => 1, 'value' => $this->t('Modules')->render(), ]; $url = Url::fromUserInput('/admin/modules')->setAbsolute()->toString(); $elements[] = [ 'type' => 'paragraph', 'level' => 2, 'value' => $this->t('This section provides information about enabled modules : @parameter')->render(), 'parameters' => [ 0 => [ 'type' => 'link', 'text' => $url, 'src' => $url, ], ], ]; $enabledModules = $this->pluginElements(); $this->removeDisabledElements($enabledModules); $info = $this->extensionList->getAllInstalledInfo(); foreach (array_keys($enabledModules) as $module) { $helpUrl = $url = Url::fromUserInput('/admin/help/' . $module)->setAbsolute()->toString(); $description = $info[$module]['description']; $elements[] = [ 'type' => 'title', 'level' => 2, 'value' => $this->moduleHandler->getName($module), ]; $elements[] = [ 'type' => 'paragraph', 'level' => 3, 'value' => $description, ]; $elements[] = [ 'type' => 'paragraph', 'level' => 3, 'value' => $this->t( 'More about @type at : @parameter', [ '@type' => $this->moduleHandler->getName($module), ] )->render(), 'parameters' => [ 0 => [ 'type' => 'link', 'text' => $helpUrl, 'src' => $helpUrl, ], ], ]; } return $elements; } }
src/Plugin/DocumentationGeneratorChapterBase.php +15 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Extension\ExtensionList; /** * Base class for Documentation Generator Chapter plugins. Loading Loading @@ -46,6 +47,13 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D */ protected $configFactory; /** * The Module Extension List . * * @var \Drupal\Core\Extension\ExtensionList */ protected $extensionList; /** * The constructor. * Loading @@ -63,6 +71,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D * The module handler. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. * @param \Drupal\Core\Extension\ExtensionList $extensionList * The module extension list. */ public function __construct( array $configuration, Loading @@ -71,7 +81,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D EntityTypeManagerInterface $entityTypeManager, EntityfieldManagerInterface $entityFieldManager, ModuleHandlerInterface $moduleHandler, ConfigFactoryInterface $configFactory ConfigFactoryInterface $configFactory, ExtensionList $extensionList, ) { parent::__construct( $configuration, Loading @@ -83,6 +94,7 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D $this->entityFieldManager = $entityFieldManager; $this->moduleHandler = $moduleHandler; $this->configFactory = $configFactory; $this->extensionList = $extensionList; } /** Loading @@ -101,7 +113,8 @@ abstract class DocumentationGeneratorChapterBase extends PluginBase implements D $container->get('entity_type.manager'), $container->get('entity_field.manager'), $container->get('module_handler'), $container->get('config.factory') $container->get('config.factory'), $container->get('extension.list.module') ); } Loading
src/Plugin/DocumentationGeneratorChapterManager.php +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\documentation_generator\Plugin; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Traversable; /** * Provides the Documentation Generator Chapter plugin manager. Loading @@ -24,7 +23,7 @@ class DocumentationGeneratorChapterManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct( Traversable $namespaces, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler ) { Loading
src/Plugin/DocumentationGeneratorRenderManager.php +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Drupal\documentation_generator\Plugin; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Traversable; /** * Provides the Documentation Generator Render plugin manager. Loading @@ -24,7 +23,7 @@ class DocumentationGeneratorRenderManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct( Traversable $namespaces, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler ) { Loading