Browse Source

Move Logger (#264)

* Move Updater [TEST_UPDATE=true]

* Use logger after enabling module [TEST_UPDATE=true]

* Empty commit

* Rename logger.thunder_updater into thunder_updater.logger

* Remove exception

* Trigger update test [TEST_UPDATE=true]

* Add dependencies [TEST_UPDATE=true]

* Correct update hook number
tags/3.3.0-beta1
Christian Fritsch GitHub 3 years ago
parent
commit
671b552a19
9 changed files with 99 additions and 55 deletions
  1. +21
    -2
      modules/thunder_article/thunder_article.install
  2. +18
    -18
      modules/thunder_media/thunder_media.install
  3. +21
    -2
      modules/thunder_paragraphs/thunder_paragraphs.install
  4. +3
    -3
      modules/thunder_updater/src/UpdateLogger.php
  5. +1
    -2
      modules/thunder_updater/src/Updater.php
  6. +2
    -4
      modules/thunder_updater/src/UpdaterInterface.php
  7. +2
    -0
      modules/thunder_updater/thunder_updater.services.yml
  8. +31
    -22
      thunder.install
  9. +0
    -2
      thunder.services.yml

+ 21
- 2
modules/thunder_article/thunder_article.install View File

@@ -7,6 +7,25 @@

use Drupal\Core\Entity\Entity\EntityViewDisplay;

/**
* Update hook dependencies.
*
* 1. Dependency on Thunder Updater module.
*
* @return mixed
* Returns list of update hook dependencies.
*/
function thunder_article_update_dependencies() {

$installThunderUpdaterHook = ['thunder' => 8103];

$dependencies['thunder_article'] = [
8101 => $installThunderUpdaterHook,
];

return $dependencies;
}

/**
* Enable thunder_paragraphs.
*/
@@ -32,8 +51,8 @@ function thunder_article_update_8001() {
*/
function thunder_article_update_8101() {

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\thunder_updater\Updater $updater */


+ 18
- 18
modules/thunder_media/thunder_media.install View File

@@ -136,8 +136,8 @@ function thunder_media_update_8004() {
* Update dropzonejs widget file extension filtering for images.
*/
function thunder_media_update_8005() {
/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

// List of expected configuration for listed entity browsers.
@@ -223,8 +223,8 @@ function thunder_media_update_8007() {
*/
function thunder_media_update_8008() {

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');

/** @var \Drupal\thunder_media\Updater $mediaUpdater */
$mediaUpdater = \Drupal::service('thunder_updater');
@@ -287,8 +287,8 @@ function thunder_media_update_8009() {
$configsToUpdate['field.field.media.image.field_image']['required'] = TRUE;
$configsToUpdate['field.field.media.video.field_media_video_embed_field']['required'] = TRUE;

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\thunder_media\Updater $mediaUpdater */
@@ -314,8 +314,8 @@ function thunder_media_update_8009() {
* Activate support for responsive images with Blazy.
*/
function thunder_media_update_8010() {
/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\thunder_media\Updater $mediaUpdater */
@@ -415,8 +415,8 @@ function thunder_media_update_8012() {
// New configuration that should be applied.
$newConfig['content']['field_image']['settings']['preview_image_style'] = 'medium';

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

// Execute update of config with additional validation of existing config.
@@ -446,8 +446,8 @@ function thunder_media_update_8012() {
* Import slick media display view configuration.
*/
function thunder_media_update_8013() {
/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\Core\Config\StorageInterface $configStorage */
@@ -490,8 +490,8 @@ function thunder_media_update_8013() {
* Remove "Language" filter from media browsers.
*/
function thunder_media_update_8101() {
/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\thunder_updater\Updater $thunderUpdater */
@@ -541,8 +541,8 @@ function thunder_media_update_8101() {
*/
function thunder_media_update_8102() {

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

\Drupal::service('module_installer')->install([
@@ -653,8 +653,8 @@ function thunder_media_update_8102() {
*/
function thunder_media_update_8103() {

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

// List of configurations that should be checked for existence.


+ 21
- 2
modules/thunder_paragraphs/thunder_paragraphs.install View File

@@ -8,6 +8,25 @@
use Drupal\Component\Utility\DiffArray;
use Drupal\Component\Utility\NestedArray;

/**
* Update hook dependencies.
*
* 1. Dependency on Thunder Updater module.
*
* @return mixed
* Returns list of update hook dependencies.
*/
function thunder_paragraphs_update_dependencies() {

$installThunderUpdaterHook = ['thunder' => 8103];

$dependencies['thunder_paragraphs'] = [
8001 => $installThunderUpdaterHook,
];

return $dependencies;
}

/**
* Change gallery paragraph to use simple inline form widget.
*/
@@ -41,8 +60,8 @@ function thunder_paragraphs_update_8001() {
['content', 'field_media', 'settings', 'match_operator'],
];

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

/** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */


src/ThunderUpdateLogger.php → modules/thunder_updater/src/UpdateLogger.php View File

@@ -1,6 +1,6 @@
<?php

namespace Drupal\thunder;
namespace Drupal\thunder_updater;

use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;
@@ -12,9 +12,9 @@ use Psr\Log\LogLevel;
* And it also provides output of logs for Drush command, when update is
* executed over drush command.
*
* @package Drupal\thunder
* @package Drupal\thunder_updater
*/
class ThunderUpdateLogger extends AbstractLogger {
class UpdateLogger extends AbstractLogger {

/**
* Container for logs.

+ 1
- 2
modules/thunder_updater/src/Updater.php View File

@@ -8,7 +8,6 @@ use Drupal\Core\Extension\MissingDependencyException;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\thunder\ThunderUpdateLogger;
use Drupal\thunder_updater\Entity\Update;
use Drupal\user\SharedTempStoreFactory;
use Drupal\Component\Utility\DiffArray;
@@ -291,7 +290,7 @@ class Updater implements UpdaterInterface {
/**
* {@inheritdoc}
*/
public function installModules(array $modules, ThunderUpdateLogger $updateLogger) {
public function installModules(array $modules, UpdateLogger $updateLogger) {

$successful = [];



+ 2
- 4
modules/thunder_updater/src/UpdaterInterface.php View File

@@ -2,8 +2,6 @@

namespace Drupal\thunder_updater;

use Drupal\thunder\ThunderUpdateLogger;

/**
* Interface for the Update entity.
*/
@@ -74,9 +72,9 @@ interface UpdaterInterface {
*
* @param array $modules
* Key is name of the checkbox, value name of the module.
* @param \Drupal\thunder\ThunderUpdateLogger $updateLogger
* @param \Drupal\thunder_updater\UpdateLogger $updateLogger
* Logger service.
*/
public function installModules(array $modules, ThunderUpdateLogger $updateLogger);
public function installModules(array $modules, UpdateLogger $updateLogger);

}

+ 2
- 0
modules/thunder_updater/thunder_updater.services.yml View File

@@ -2,3 +2,5 @@ services:
thunder_updater:
class: Drupal\thunder_updater\Updater
arguments: ['@user.shared_tempstore', '@config.factory', '@module_installer', '@current_user']
thunder_updater.logger:
class: Drupal\thunder_updater\UpdateLogger

+ 31
- 22
thunder.install View File

@@ -10,7 +10,25 @@ use Drupal\user\Entity\User;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\metatag\Entity\MetatagDefaults;
use Drupal\field\Entity\FieldConfig;
use Drupal\Core\Extension\MissingDependencyException;

/**
* Update hook dependencies.
*
* 1. Dependency on Thunder Updater module.
*
* @return mixed
* Returns list of update hook dependencies.
*/
function thunder_update_dependencies() {

$installThunderUpdaterHook = ['thunder' => 8103];

$dependencies['thunder'] = [
8006 => $installThunderUpdaterHook,
];

return $dependencies;
}

/**
* Install the thunder installation profile.
@@ -252,8 +270,8 @@ function thunder_update_8006() {
'config_update',
]);

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

$configs = [
@@ -314,20 +332,11 @@ function thunder_update_8102() {
*/
function thunder_update_8103() {

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = Drupal::service('logger.thunder_update');
$updateLogger->cleanLogs();

$moduleInstaller = \Drupal::service('module_installer');
\Drupal::service('module_installer')->install(['thunder_updater']);

try {
if (!$moduleInstaller->install(['thunder_updater'])) {
$updateLogger->warning(t('Unable to enable the Thunder Updater'));
}
}
catch (MissingDependencyException $e) {
$updateLogger->warning(t('Unable to enable the Thunder Updater because of missing dependencies.'));
}
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

$thunderUpdater = \Drupal::service('thunder_updater');
$thunderUpdater->markAllUpdates(FALSE);
@@ -356,8 +365,8 @@ function thunder_update_8104() {

$thunderUpdater = \Drupal::service('thunder_updater');

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

$updates = [
@@ -382,8 +391,8 @@ function thunder_update_8105() {

$thunderUpdater = \Drupal::service('thunder_updater');

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

$updates = [
@@ -408,8 +417,8 @@ function thunder_update_8106() {

$thunderUpdater = \Drupal::service('thunder_updater');

/** @var \Drupal\thunder\ThunderUpdateLogger $updateLogger */
$updateLogger = \Drupal::service('logger.thunder_update');
/** @var \Drupal\thunder_updater\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('thunder_updater.logger');
$updateLogger->cleanLogs();

$updates = [


+ 0
- 2
thunder.services.yml View File

@@ -2,5 +2,3 @@ services:
plugin.manager.thunder.optional_modules:
class: Drupal\thunder\OptionalModulesManager
parent: default_plugin_manager
logger.thunder_update:
class: Drupal\thunder\ThunderUpdateLogger

Loading…
Cancel
Save