diff --git a/src/Commands/UpdateFixtureCommands.php b/src/Commands/UpdateFixtureCommands.php index 4d926f9850f9835b66f47bd7452dcb18e10f76d2..4cf7f0fc9c11d513e1c0918eec027a52226bac6f 100644 --- a/src/Commands/UpdateFixtureCommands.php +++ b/src/Commands/UpdateFixtureCommands.php @@ -28,50 +28,13 @@ class UpdateFixtureCommands extends DrushCommands { use StringTranslationTrait; - /** - * Logger service. - * - * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface - */ - private $loggerChannelFactory; - - /** - * The EnabledSourceHandler. - * - * @var \Drupal\project_browser\EnabledSourceHandler - */ - protected $enabledSource; - - /** - * The event dispatcher service. - * - * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @var \Drupal\project_browser\ProjectBrowserFixtureHelper - */ - protected ProjectBrowserFixtureHelper $fixtureHelper; - - /** - * Constructs a new UpdateFixtureCommands object. - * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Logger service. - * @param \Drupal\project_browser\EnabledSourceHandler $enabled_source - * The enabled source. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher - * Event dispatcher service. - * @param \Drupal\project_browser\ProjectBrowserFixtureHelper $fixture_helper - * The Project Browser fixture helper. - */ - public function __construct(LoggerChannelFactoryInterface $loggerChannelFactory, EnabledSourceHandler $enabled_source, EventDispatcherInterface $event_dispatcher, ProjectBrowserFixtureHelper $fixture_helper) { + public function __construct( + private readonly LoggerChannelFactoryInterface $loggerChannelFactory, + private readonly EnabledSourceHandler $enabledSource, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly ProjectBrowserFixtureHelper $fixtureHelper, + ) { parent::__construct(); - $this->loggerChannelFactory = $loggerChannelFactory; - $this->enabledSource = $enabled_source; - $this->eventDispatcher = $event_dispatcher; - $this->fixtureHelper = $fixture_helper; } /** diff --git a/src/ComposerInstaller/Validator/CoreNotUpdatedValidator.php b/src/ComposerInstaller/Validator/CoreNotUpdatedValidator.php index d80467d047258339cf8a856054b8140063070591..f6d28c80bcd01d8baa9e46ef0f0f693f87e0fdb9 100644 --- a/src/ComposerInstaller/Validator/CoreNotUpdatedValidator.php +++ b/src/ComposerInstaller/Validator/CoreNotUpdatedValidator.php @@ -27,8 +27,10 @@ final class CoreNotUpdatedValidator implements EventSubscriberInterface { * @param \Drupal\package_manager\ComposerInspector $composerInspector * The Composer inspector service. */ - public function __construct(private PathLocator $pathLocator, private ComposerInspector $composerInspector) { - } + public function __construct( + private readonly PathLocator $pathLocator, + private readonly ComposerInspector $composerInspector, + ) {} /** * Validates Drupal core was not updated during project install. diff --git a/src/ComposerInstaller/Validator/PackageNotInstalledValidator.php b/src/ComposerInstaller/Validator/PackageNotInstalledValidator.php index 4d5e3d34b8fd6b7e19cae9c7d4b71ce3c269d7ef..1cc5b91794d0a256e61e3a3aa249c9e91b6998df 100644 --- a/src/ComposerInstaller/Validator/PackageNotInstalledValidator.php +++ b/src/ComposerInstaller/Validator/PackageNotInstalledValidator.php @@ -27,8 +27,10 @@ final class PackageNotInstalledValidator implements EventSubscriberInterface { * @param \Drupal\package_manager\ComposerInspector $composerInspector * The Composer inspector service. */ - public function __construct(private PathLocator $pathLocator, private ComposerInspector $composerInspector) { - } + public function __construct( + private readonly PathLocator $pathLocator, + private readonly ComposerInspector $composerInspector, + ) {} /** * Validates that packages are not already installed with composer. diff --git a/src/Controller/BrowserController.php b/src/Controller/BrowserController.php index 3c0e05030287cfb0b19da6f7960edb74d54809e2..8844705957a2e5bafb583fc60e3d64489355d618 100644 --- a/src/Controller/BrowserController.php +++ b/src/Controller/BrowserController.php @@ -7,7 +7,6 @@ namespace Drupal\project_browser\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\InfoParserException; use Drupal\Core\Extension\ModuleExtensionList; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\project_browser\EnabledSourceHandler; use Drupal\project_browser\InstallReadiness; use Drupal\project_browser\Plugin\ProjectBrowserSourceBase; @@ -22,77 +21,18 @@ use Symfony\Component\HttpFoundation\RequestStack; */ class BrowserController extends ControllerBase { - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * The module extension list. - * - * @var \Drupal\Core\Extension\ModuleExtensionList - */ - protected $moduleList; - - /** - * The request stack. - * - * @var \Symfony\Component\HttpFoundation\RequestStack - */ - protected $requestStack; - - /** - * The EnabledSourceHandler. - * - * @var \Drupal\project_browser\EnabledSourceHandler - */ - protected $enabledSource; - - /** - * ProjectBrowser cache bin. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $cacheBin; - - /** - * The install readiness service. - * - * @var \Drupal\project_browser\InstallReadiness - */ - private $installReadiness; - - /** - * Build the project browser controller. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - * @param \Drupal\Core\Extension\ModuleExtensionList $module_list - * The module extension list. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The request stack. - * @param \Drupal\project_browser\EnabledSourceHandler $enabled_source - * The enabled source. - * @param \Drupal\project_browser\InstallReadiness|null $install_readiness - * The install readiness service. - */ - public function __construct(ModuleHandlerInterface $module_handler, ModuleExtensionList $module_list, RequestStack $request_stack, EnabledSourceHandler $enabled_source, InstallReadiness|NULL $install_readiness) { - $this->moduleHandler = $module_handler; - $this->moduleList = $module_list; - $this->requestStack = $request_stack; - $this->enabledSource = $enabled_source; - $this->cacheBin = $this->cache('project_browser'); - $this->installReadiness = $install_readiness; - } + public function __construct( + private readonly ModuleExtensionList $moduleList, + private readonly RequestStack $requestStack, + private readonly EnabledSourceHandler $enabledSource, + private readonly InstallReadiness|NULL $installReadiness, + ) {} /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( - $container->get('module_handler'), $container->get('extension.list.module'), $container->get('request_stack'), $container->get('project_browser.enabled_source'), @@ -150,7 +90,7 @@ class BrowserController extends ControllerBase { 'modules' => $modules_status, 'drupal_version' => \Drupal::VERSION, 'drupal_core_compatibility' => \Drupal::CORE_COMPATIBILITY, - 'module_path' => $this->moduleHandler->getModule('project_browser')->getPath(), + 'module_path' => $this->moduleHandler()->getModule('project_browser')->getPath(), 'origin_url' => $request->getSchemeAndHttpHost() . $request->getBaseUrl(), 'special_ids' => $this->getSpecialIds(), 'sort_options' => $sort_options, diff --git a/src/Controller/InstallerController.php b/src/Controller/InstallerController.php index ef19261f850e54df92b8d4f37b9cc3cf1dcb60c2..aa3242927206dc6974f6455d955682849d4e3246 100644 --- a/src/Controller/InstallerController.php +++ b/src/Controller/InstallerController.php @@ -6,6 +6,7 @@ use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ModuleInstallerInterface; +use Drupal\Core\TempStore\SharedTempStore; use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\Core\Url; use Drupal\package_manager\Exception\StageException; @@ -48,79 +49,22 @@ class InstallerController extends ControllerBase { */ protected const STAGE_STATUS_OK = 0; - /** - * The installer. - * - * @var \Drupal\project_browser\ComposerInstaller\Installer - */ - private $installer; - /** * The Project Browser tempstore object. * * @var \Drupal\Core\TempStore\SharedTempStore */ - protected $projectBrowserTempStore; - - /** - * The shared tempstore object. - * - * @var \Drupal\Core\TempStore\SharedTempStore - */ - protected $sharedTempStore; - - /** - * The module installer. - * - * @var \Drupal\Core\Extension\ModuleInstallerInterface - */ - protected $moduleInstaller; - - /** - * The EnabledSourceHandler. - * - * @var \Drupal\project_browser\EnabledSourceHandler - */ - protected $enabledSourceHandler; - - /** - * The time service. - * - * @var \Drupal\Component\Datetime\TimeInterface - */ - protected $time; - - /** - * A logger instance. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * Constructs an InstallerController object. - * - * @param \Drupal\project_browser\ComposerInstaller\Installer $installer - * The installer. - * @param \Drupal\Core\TempStore\SharedTempStoreFactory $shared_temp_store_factory - * The shared tempstore factory. - * @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer - * The module installer. - * @param \Drupal\project_browser\EnabledSourceHandler $enabled_source - * The enabled source. - * @param \Drupal\Component\Datetime\TimeInterface $time - * The time service. - * @param \Psr\Log\LoggerInterface $logger - * A logger instance. - */ - public function __construct(Installer $installer, SharedTempStoreFactory $shared_temp_store_factory, ModuleInstallerInterface $module_installer, EnabledSourceHandler $enabled_source, TimeInterface $time, LoggerInterface $logger) { - $this->installer = $installer; + protected SharedTempStore $projectBrowserTempStore; + + public function __construct( + private readonly Installer $installer, + SharedTempStoreFactory $shared_temp_store_factory, + private readonly ModuleInstallerInterface $moduleInstaller, + private readonly EnabledSourceHandler $enabledSourceHandler, + private readonly TimeInterface $time, + private readonly LoggerInterface $logger, + ) { $this->projectBrowserTempStore = $shared_temp_store_factory->get('project_browser'); - $this->sharedTempStore = $shared_temp_store_factory; - $this->moduleInstaller = $module_installer; - $this->enabledSourceHandler = $enabled_source; - $this->time = $time; - $this->logger = $logger; } /** diff --git a/src/Controller/ProjectBrowserEndpointController.php b/src/Controller/ProjectBrowserEndpointController.php index 78b849ab17fe8a408c65681d1399ccae74e30831..d5d1f8d8ec0a925695030be20223655029a06fe8 100644 --- a/src/Controller/ProjectBrowserEndpointController.php +++ b/src/Controller/ProjectBrowserEndpointController.php @@ -5,6 +5,7 @@ namespace Drupal\project_browser\Controller; // cspell:ignore tabwise use Drupal\Component\Serialization\Json; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\project_browser\EnabledSourceHandler; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -17,31 +18,11 @@ use Symfony\Component\HttpFoundation\Response; */ class ProjectBrowserEndpointController extends ControllerBase { - /** - * The EnabledSourceHandler. - * - * @var \Drupal\project_browser\EnabledSourceHandler - */ - protected $enabledSource; - - /** - * ProjectBrowser cache bin. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $cacheBin; - - /** - * ProjectBrowserEndpointController constructor. - * - * @param \Drupal\project_browser\EnabledSourceHandler $enabled_source - * The enabled source. - */ - public function __construct(EnabledSourceHandler $enabled_source) { + public function __construct( + private readonly EnabledSourceHandler $enabledSource, + private readonly CacheBackendInterface $cacheBin, + ) { $plugin_ids = []; - $this->enabledSource = $enabled_source; - $this->cacheBin = $this->cache('project_browser'); - $current_sources = $this->enabledSource->getCurrentSources(); foreach ($current_sources as $source) { $plugin_ids[] = $source->getPluginId(); @@ -60,6 +41,7 @@ class ProjectBrowserEndpointController extends ControllerBase { public static function create(ContainerInterface $container) { return new static( $container->get('project_browser.enabled_source'), + $container->get('cache.project_browser'), ); } diff --git a/src/EnabledSourceHandler.php b/src/EnabledSourceHandler.php index e45925525e7d0f3ffab7935f3d83179c1ea81f25..585c09ba9b3f32b00d67d18090bd7f4f4d5ff143 100644 --- a/src/EnabledSourceHandler.php +++ b/src/EnabledSourceHandler.php @@ -11,42 +11,11 @@ use Psr\Log\LoggerInterface; */ class EnabledSourceHandler { - /** - * A logger instance. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * The config factory interface. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** - * The ProjectBrowserSourceManager. - * - * @var \Drupal\project_browser\plugin\ProjectBrowserSourceManager - */ - private $pluginManager; - - /** - * EnabledSourceHandler constructor. - * - * @param \Psr\Log\LoggerInterface $logger - * A logger instance. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. - * @param \Drupal\project_browser\plugin\ProjectBrowserSourceManager $plugin_manager - * The plugin manager. - */ - public function __construct(LoggerInterface $logger, ConfigFactoryInterface $config_factory, ProjectBrowserSourceManager $plugin_manager) { - $this->logger = $logger; - $this->configFactory = $config_factory; - $this->pluginManager = $plugin_manager; - } + public function __construct( + private readonly LoggerInterface $logger, + private readonly ConfigFactoryInterface $configFactory, + private readonly ProjectBrowserSourceManager $pluginManager, + ) {} /** * Returns all plugin instances corresponding to the enabled_source config. diff --git a/src/Event/UpdateFixtureEvent.php b/src/Event/UpdateFixtureEvent.php index f4eb0cdb6b663e4e47d7f9ac499f5ed0807d8404..abf15ec1ce7555388d5f7bf0fd0adb3000069884 100644 --- a/src/Event/UpdateFixtureEvent.php +++ b/src/Event/UpdateFixtureEvent.php @@ -7,21 +7,8 @@ use Symfony\Contracts\EventDispatcher\Event; class UpdateFixtureEvent extends Event { - /** - * The EnabledSourceHandler. - * - * @var \Drupal\project_browser\EnabledSourceHandler - */ - public $enabledSource; - - /** - * Constructs the object. - * - * @param \Drupal\project_browser\EnabledSourceHandler $enabled_source - * The enabled source. - */ - public function __construct(EnabledSourceHandler $enabled_source) { - $this->enabledSource = $enabled_source; - } + public function __construct( + public EnabledSourceHandler $enabledSource, + ) {} } diff --git a/src/EventSubscriber/DisableAddNewModuleRouteSubscriber.php b/src/EventSubscriber/DisableAddNewModuleRouteSubscriber.php index 7aea49c9e5e2ed5e6fb5c927d80a1adad7b9b55b..20c15864135429915b1d22878a4f7735296e2ab3 100644 --- a/src/EventSubscriber/DisableAddNewModuleRouteSubscriber.php +++ b/src/EventSubscriber/DisableAddNewModuleRouteSubscriber.php @@ -17,8 +17,9 @@ class DisableAddNewModuleRouteSubscriber extends RouteSubscriberBase { * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ - public function __construct(protected ConfigFactoryInterface $configFactory) { - } + public function __construct( + protected ConfigFactoryInterface $configFactory + ) {} /** * {@inheritdoc} diff --git a/src/EventSubscriber/UpdateFixtureSubscriber.php b/src/EventSubscriber/UpdateFixtureSubscriber.php index a6823b59b1a35ed3f7892d2ff58d2c734edb93ea..3c28d63b1ae710c04d613a55777d716edc86372a 100644 --- a/src/EventSubscriber/UpdateFixtureSubscriber.php +++ b/src/EventSubscriber/UpdateFixtureSubscriber.php @@ -12,14 +12,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ class UpdateFixtureSubscriber implements EventSubscriberInterface { - /** - * @var \Drupal\project_browser\ProjectBrowserFixtureHelper - */ - protected ProjectBrowserFixtureHelper $fixtureHelper; - - public function __construct(ProjectBrowserFixtureHelper $fixture_helper) { - $this->fixtureHelper = $fixture_helper; - } + public function __construct( + private readonly ProjectBrowserFixtureHelper $fixtureHelper, + ) {} /** * {@inheritdoc} diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 228a7d4a2c37c41162b8d176b352a753bf0c1f48..46270e294662c212aa4ecd0473d87edc03255102 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -17,82 +17,16 @@ use Symfony\Component\DependencyInjection\ContainerInterface; */ class SettingsForm extends ConfigFormBase { - /** - * The Project Browser Source Manager. - * - * @var \Drupal\project_browser\Plugin\ProjectBrowserSourceManager - */ - protected $manager; - - /** - * ProjectBrowser cache bin. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $cacheBin; - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * The route builder. - * - * @var \Drupal\Core\Routing\RouteBuilderInterface - */ - protected $routeBuilder; - - /** - * A context link manager instance. - * - * @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface - */ - protected $contextualLinkManager; - - /** - * The render cache. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $renderCache; - - /** - * Constructs a \Drupal\project_browser\Form\SettingsForm object. - * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The factory for configuration objects. - * @param \Drupal\project_browser\Plugin\ProjectBrowserSourceManager $manager - * The plugin manager. - * @param \Drupal\Core\Cache\CacheBackendInterface $project_browser_cache - * The cache bin. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder - * The route builder. - * @param \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface $contextual_link_manager - * A context link manager instance. - * @param \Drupal\Core\Cache\CacheBackendInterface $render_cache - * The render cache. - */ public function __construct( ConfigFactoryInterface $config_factory, - ProjectBrowserSourceManager $manager, - CacheBackendInterface $project_browser_cache, - ModuleHandlerInterface $module_handler, - RouteBuilderInterface $route_builder, - CachedDiscoveryInterface $contextual_link_manager, - CacheBackendInterface $render_cache + private readonly ProjectBrowserSourceManager $manager, + private readonly CacheBackendInterface $cacheBin, + private readonly ModuleHandlerInterface $moduleHandler, + private readonly RouteBuilderInterface $routeBuilder, + private readonly CachedDiscoveryInterface $contextualLinkManager, + private readonly CacheBackendInterface $renderCache, ) { parent::__construct($config_factory); - $this->manager = $manager; - $this->cacheBin = $project_browser_cache; - $this->moduleHandler = $module_handler; - $this->routeBuilder = $route_builder; - $this->contextualLinkManager = $contextual_link_manager; - $this->renderCache = $render_cache; } /** diff --git a/src/InstallReadiness.php b/src/InstallReadiness.php index 7f310fb2f988efcfb56e18611a352ec63af18eca..687d842fe644a2346782bb1ec1b10795348a25b0 100644 --- a/src/InstallReadiness.php +++ b/src/InstallReadiness.php @@ -10,34 +10,13 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * Defines Installer service. */ class InstallReadiness { - use StatusCheckTrait; - /** - * The installer. - * - * @var \Drupal\project_browser\ComposerInstaller\Installer - */ - private $installer; - - /** - * The event dispatcher service. - * - * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface - */ - protected $eventDispatcher; + use StatusCheckTrait; - /** - * InstallReadiness constructor. - * - * @param \Drupal\project_browser\ComposerInstaller\Installer $installer - * The installer. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher - * The event dispatcher. - */ - public function __construct(Installer $installer, EventDispatcherInterface $event_dispatcher) { - $this->installer = $installer; - $this->eventDispatcher = $event_dispatcher; - } + public function __construct( + private readonly Installer $installer, + private readonly EventDispatcherInterface $eventDispatcher, + ) {} /** * Checks if the environment meets Package Manager install requirements. diff --git a/src/Plugin/ProjectBrowserSource/DrupalCore.php b/src/Plugin/ProjectBrowserSource/DrupalCore.php index d7c091c94ffda86db4e0eb5e421aaa314667ef08..df34dab72a3a39681d08639ff0bcf03d8d941a0f 100644 --- a/src/Plugin/ProjectBrowserSource/DrupalCore.php +++ b/src/Plugin/ProjectBrowserSource/DrupalCore.php @@ -44,38 +44,14 @@ class DrupalCore extends ProjectBrowserSourceBase implements ContainerFactoryPlu */ const MAINTAINED = 'maintained'; - /** - * ProjectBrowser cache bin. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $cacheBin; - - /** - * The module extension list. - * - * @var \Drupal\Core\Extension\ModuleExtensionList - */ - protected $moduleExtensionList; - - /** - * Constructs a DrupalCore source plugin. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin ID for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Cache\CacheBackendInterface $cache_bin - * The cache bin. - * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module - * The object that provides a list of all extension modules. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, CacheBackendInterface $cache_bin, ModuleExtensionList $extension_list_module) { + public function __construct( + array $configuration, + $plugin_id, + $plugin_definition, + private readonly CacheBackendInterface $cacheBin, + private readonly ModuleExtensionList $moduleExtensionList, + ) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->cacheBin = $cache_bin; - $this->moduleExtensionList = $extension_list_module; } /** diff --git a/src/Plugin/ProjectBrowserSource/MockDrupalDotOrg.php b/src/Plugin/ProjectBrowserSource/MockDrupalDotOrg.php index bba1aaf9181aaecec7109d6acb5834a838e0f36c..699044de2098d06515ad941b3633db3bbd2a2171 100644 --- a/src/Plugin/ProjectBrowserSource/MockDrupalDotOrg.php +++ b/src/Plugin/ProjectBrowserSource/MockDrupalDotOrg.php @@ -52,68 +52,17 @@ class MockDrupalDotOrg extends ProjectBrowserSourceBase implements ContainerFact */ const MAINTAINED_VALUES = [13028, 19370, 9990]; - /** - * A logger instance. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * The database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $database; - - /** - * The HTTP client. - * - * @var \GuzzleHttp\ClientInterface - */ - protected $httpClient; - - /** - * The state object. - * - * @var \Drupal\Core\State\StateInterface - */ - protected $state; - - /** - * ProjectBrowser cache bin. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $cacheBin; - - /** - * Constructs a MockDrupalDotOrg object. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin ID for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Psr\Log\LoggerInterface $logger - * A logger instance. - * @param \Drupal\Core\Database\Connection $database - * The database connection to be used. - * @param \GuzzleHttp\ClientInterface $http_client - * A Guzzle client object. - * @param \Drupal\Core\State\StateInterface $state - * The state object. - * @param \Drupal\Core\Cache\CacheBackendInterface $cache_bin - * The cache bin. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger, Connection $database, ClientInterface $http_client, StateInterface $state, CacheBackendInterface $cache_bin) { + public function __construct( + array $configuration, + $plugin_id, + $plugin_definition, + private readonly LoggerInterface $logger, + private readonly Connection $database, + private readonly ClientInterface $httpClient, + private readonly StateInterface $state, + private readonly CacheBackendInterface $cacheBin, + ) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->logger = $logger; - $this->database = $database; - $this->httpClient = $http_client; - $this->state = $state; - $this->cacheBin = $cache_bin; } /** diff --git a/src/ProjectBrowser/ProjectsResultsPage.php b/src/ProjectBrowser/ProjectsResultsPage.php index 81deedb94da6a4f38362c8bb2493210c3b10c690..37dc62cd25c78e7d632b7e089ee553707ac4fd41 100644 --- a/src/ProjectBrowser/ProjectsResultsPage.php +++ b/src/ProjectBrowser/ProjectsResultsPage.php @@ -6,62 +6,13 @@ namespace Drupal\project_browser\ProjectBrowser; * One page of search results from a query. */ class ProjectsResultsPage { - /** - * Total results that match the query. - * - * @var int - */ - public $totalResults; - /** - * List of projects for one page of the query. - * - * @var \Drupal\project_browser\ProjectBrowser\Project[] - * An array of projects. - */ - public $list = []; - - /** - * Plugin label to display in front-end. - * - * @var string - */ - public $pluginLabel; - - /** - * Plugin ID to be used in API. - * - * @var string - */ - public $pluginId; - - /** - * Set whether Package Manager is required or not. - * - * @var bool - */ - public $isPackageManagerRequired; - - /** - * Constructor. - * - * @param int $total_results - * The total results that match the query. - * @param array $list - * The list of projects for one page. - * @param string $plugin_label - * Plugin label to display in front-end. - * @param string $plugin_id - * Plugin ID to be used in the API. - * @param bool $is_package_manager_required - * Whether Package Manager is required or not. - */ - public function __construct(int $total_results, array $list, string $plugin_label, string $plugin_id, bool $is_package_manager_required) { - $this->totalResults = $total_results; - $this->list = $list; - $this->pluginLabel = $plugin_label; - $this->pluginId = $plugin_id; - $this->isPackageManagerRequired = $is_package_manager_required; - } + public function __construct( + public int $totalResults, + public array $list, + public string $pluginLabel, + public string $pluginId, + public bool $isPackageManagerRequired, + ) {} } diff --git a/src/ProjectBrowserFixtureHelper.php b/src/ProjectBrowserFixtureHelper.php index 816c903fb397d690618020b76a7fbb08af1da4b4..e8a00c641c1b864b387c6c7a32f405c3056f6145 100644 --- a/src/ProjectBrowserFixtureHelper.php +++ b/src/ProjectBrowserFixtureHelper.php @@ -19,38 +19,11 @@ use GuzzleHttp\TransferStats; */ class ProjectBrowserFixtureHelper { - /** - * @var \Drupal\Core\Database\Connection - */ - private Connection $connection; - - /** - * @var \Drupal\Core\State\StateInterface - */ - private StateInterface $state; - - /** - * The HTTP client. - * - * @var \GuzzleHttp\ClientInterface - */ - protected ClientInterface $httpClient; - - /** - * Constructs a new ProjectBrowserFixtureHelper. - * - * @param \Drupal\Core\Database\Connection $connection - * The database connection. - * @param \Drupal\Core\State\StateInterface $state - * The state key-value store. - * @param \GuzzleHttp\ClientInterface $http_client - * The HTTP client. - */ - public function __construct(Connection $connection, StateInterface $state, ClientInterface $http_client) { - $this->connection = $connection; - $this->state = $state; - $this->httpClient = $http_client; - } + public function __construct( + private readonly Connection $connection, + private readonly StateInterface $state, + private readonly ClientInterface $httpClient, + ) {} /** * Inserts data into Project Browser module tables. diff --git a/src/Routing/ProjectBrowserRoutes.php b/src/Routing/ProjectBrowserRoutes.php index 24db298719f31b6f2b4a5a832bd796c2bb86196b..7fac98d0232798645f205779ebad5341d321448e 100644 --- a/src/Routing/ProjectBrowserRoutes.php +++ b/src/Routing/ProjectBrowserRoutes.php @@ -16,20 +16,9 @@ use Symfony\Component\Routing\Route; */ class ProjectBrowserRoutes implements ContainerInjectionInterface { - /** - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - private ModuleHandlerInterface $moduleHandler; - - /** - * Constructs a new ProjectBrowserRoutes object. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - */ - public function __construct(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; - } + public function __construct( + private readonly ModuleHandlerInterface $moduleHandler, + ) {} /** * {@inheritdoc}