diff -u b/config_update_ui/config_update_ui.drush.inc b/config_update_ui/config_update_ui.drush.inc --- b/config_update_ui/config_update_ui.drush.inc +++ b/config_update_ui/config_update_ui.drush.inc @@ -2,9 +2,11 @@ /** * @file - * Drush commands for the Configuration Update Reports module. + * Drush 8 commands for the Configuration Update Reports module. */ +use Drupal\config_update_ui\Logger\ConfigUpdateUiDrush8Logger; + /** * Implements hook_drush_command(). */ @@ -258,12 +260,12 @@ } /** - * Bootstraps the Drush Commands CLI service and set the logger to Drush 8. + * Instantiates and returns the Drush Commands CLI service for Drush 8. */ function drush_config_update_ui_cli_service() { /** @var \Drupal\config_update_ui\ConfigUpdateUiCliService $config_update_ui_service */ $config_update_ui_service = \Drupal::service('config_update_ui.cli'); - $logger = \Drupal::service('logger.config_update_ui.drush8'); + $logger = new ConfigUpdateUiDrush8Logger(\Drupal::service('logger.log_message_parser')); $config_update_ui_service->setLogger($logger); return $config_update_ui_service; diff -u b/config_update_ui/config_update_ui.services.yml b/config_update_ui/config_update_ui.services.yml --- b/config_update_ui/config_update_ui.services.yml +++ b/config_update_ui/config_update_ui.services.yml @@ -4,6 +4 @@ - arguments: ['@entity.manager', '@config_update.config_diff', '@config_update.config_list', '@config_update.config_update'] - logger.config_update_ui.drush8: - class: Drupal\config_update_ui\Logger\ConfigUpdateUiDrush8Logger - arguments: ['@logger.log_message_parser'] - tags: - - { name: logger } + arguments: ['@entity_type.manager', '@config_update.config_diff', '@config_update.config_list', '@config_update.config_update'] diff -u b/config_update_ui/src/Commands/ConfigUpdateUiCommands.php b/config_update_ui/src/Commands/ConfigUpdateUiCommands.php --- b/config_update_ui/src/Commands/ConfigUpdateUiCommands.php +++ b/config_update_ui/src/Commands/ConfigUpdateUiCommands.php @@ -21,7 +21,7 @@ protected $cliService; /** - * ConfigUpdateUiCommands constructor. + * Constructs a ConfigUpdateUiCommands object. * * @param \Drupal\config_update_ui\ConfigUpdateUiCliService $cliService * The CLI service which allows interoperability between Drush versions. diff -u b/config_update_ui/src/ConfigUpdateUiCliService.php b/config_update_ui/src/ConfigUpdateUiCliService.php --- b/config_update_ui/src/ConfigUpdateUiCliService.php +++ b/config_update_ui/src/ConfigUpdateUiCliService.php @@ -11,15 +11,18 @@ use Psr\Log\LoggerInterface; /** - * Class ConfigUpdateUiCliService. + * Handles all the logic for commands for various versions of Drush. * - * This class handles all the logic for Drush commands. + * To use this class, you must call the + * \Drupal\config_update_ui\ConfigUpdateUiCliService::setLogger() method before + * doing anything else. */ class ConfigUpdateUiCliService { + /** * The entity manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityManager; @@ -38,7 +41,7 @@ protected $configList; /** - * The config updater. + * The config reverter. * * @var \Drupal\config_update\ConfigReverter */ @@ -49,12 +52,21 @@ * * This differs between Drush version 8 and 9. * - * @var \Drush\Log\Logger|ConfigUpdateUiDrush8Logger + * @var \Drush\Log\Logger|\Drupal\config_update_ui\ConfigUpdateUiDrush8Logger */ protected $logger; /** - * Constructor. + * Constructs a ConfigUpdateUiCliService object. + * + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityManager + * The entity type manager. + * @param \Drupal\config_update\ConfigDiffer $configDiff + * The config differ. + * @param \Drupal\config_update\ConfigListerWithProviders $configList + * The config lister. + * @param \Drupal\config_update\ConfigReverter $configUpdate + * The config reverter. */ public function __construct(EntityTypeManagerInterface $entityManager, ConfigDiffer $configDiff, ConfigListerWithProviders $configList, ConfigReverter $configUpdate) { $this->entityManager = $entityManager; @@ -298,10 +310,12 @@ } /** - * Associates a logging object. + * Registers a logger. * * @param \Psr\Log\LoggerInterface $logger - * The logging object. + * The logging object to use. For Drush 8, you must use an object of class + * \Drupal\config_ui\ConfigUpdateUiDrush8Logger. For Drush 9 and later, + * use the output of \Drush\Drush::logger(). */ public function setLogger(LoggerInterface $logger) { $this->logger = $logger; @@ -320,7 +334,7 @@ /** * Lists differing config items. * - * Lists config items that differ from the versions provided by your + * Lists config items that differ from the versions provided by your * installed modules, themes, or install profile. See config-diff to show * what the differences are. * @@ -335,7 +349,7 @@ * @return array * An array of differing configuration items. */ - private function getDifferentItems($type, $name) { + protected function getDifferentItems($type, $name) { list($activeList, $installList, $optionalList) = $this->configList->listConfig($type, $name); $addedItems = array_diff($activeList, $installList, $optionalList); $activeAndAddedItems = array_diff($activeList, $addedItems); @@ -363,7 +377,7 @@ * @return string * The shortname for the configuration item. */ - private function getConfigShortname($type, $name) { + protected function getConfigShortname($type, $name) { $shortname = $name; if ($type != 'system.simple') { $definition = $this->entityManager->getDefinition($type); @@ -389,7 +403,7 @@ * If using Drush 8, an array of strings. If using Drush 9, a structured * data object of rows strings. */ - private function outputRows(array $output) { + protected function outputRows(array $output) { if (get_class($this->logger) === 'ConfigUpdateUiDrush8Logger') { return $output; } diff -u b/config_update_ui/src/Logger/ConfigUpdateUiDrush8Logger.php b/config_update_ui/src/Logger/ConfigUpdateUiDrush8Logger.php --- b/config_update_ui/src/Logger/ConfigUpdateUiDrush8Logger.php +++ b/config_update_ui/src/Logger/ConfigUpdateUiDrush8Logger.php @@ -9,26 +9,25 @@ use Drupal\Core\Logger\LogMessageParserInterface; /** - * Class ConfigUpdateUiDrush8Logger. - * - * This is a stand-in for Psr\Log\LoggerInterface, which Drush 9 uses. + * Provides Drush 8 logging in a class. */ class ConfigUpdateUiDrush8Logger implements LoggerInterface { use RfcLoggerTrait; /** - * The message's placeholders parser. + * The message placeholder parser. * * @var \Drupal\Core\Logger\LogMessageParserInterface */ protected $parser; /** - * Constructs a SysLog object. + * Constructs a ConfigUpdateUiDrush8Logger object. * * @param \Drupal\Core\Logger\LogMessageParserInterface $parser - * The parser to use when extracting message variables. + * The parser to use when extracting message variables. The service + * logger.log_message_parser is a good choice. */ public function __construct(LogMessageParserInterface $parser) { $this->parser = $parser; @@ -41,8 +40,8 @@ // Translate the RFC logging levels into their Drush counterparts, more or // less. // @todo ALERT, CRITICAL and EMERGENCY are considered show-stopping errors, - // and they should cause Drush to exit or panic. Not sure how to handle this, - // though. + // and they should cause Drush to exit or panic. Not sure how to handle + // this, though. switch ($level) { case RfcLogLevel::ALERT: case RfcLogLevel::CRITICAL: only in patch2: unchanged: --- a/config_update.services.yml +++ b/config_update.services.yml @@ -5,11 +5,11 @@ services: config_update.config_list: class: Drupal\config_update\ConfigListerWithProviders - arguments: ['@entity.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage', '@module_handler', '@theme_handler'] + arguments: ['@entity_type.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage', '@module_handler', '@theme_handler'] config_update.config_update: class: Drupal\config_update\ConfigReverter - arguments: ['@entity.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage', '@config.factory', '@event_dispatcher'] + arguments: ['@entity_type.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage', '@config.factory', '@event_dispatcher'] config_update.extension_storage: class: Drupal\Core\Config\ExtensionInstallStorage