diff --git a/src/Controller/BlocksController.php b/src/Controller/BlocksController.php index 78dc621dbbe9ebaea306877607b060c4b5b0ac89..61bb491f5fa26936a4bce2898741fb16d64f6b96 100644 --- a/src/Controller/BlocksController.php +++ b/src/Controller/BlocksController.php @@ -90,12 +90,12 @@ public function exportBlocks(array $form = NULL, FormStateInterface $form_state foreach ($customBlocks as $customBlock) { if (array_key_exists('drush', $form) && $form['drush'] === TRUE) { - \Drupal::logger('Exported "' . $customBlock['info'] . '"', 'ok'); + drush_log('Exported "' . $customBlock['info'] . '"', 'ok'); } StructureSyncHelper::logMessage('Exported "' . $customBlock['info'] . '"'); } - $this->messenger()->addStatus($this->t('The custom blocks have been successfully exported.')); + drupal_set_message($this->t('The custom blocks have been successfully exported.')); StructureSyncHelper::logMessage('Custom blocks exported'); } @@ -245,7 +245,7 @@ public static function deleteDeletedBlocks($blocks, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted custom blocks that were not in config', 'ok'); + drush_log('Deleted custom blocks that were not in config', 'ok'); } StructureSyncHelper::logMessage('Deleted custom blocks that were not in config'); } @@ -296,7 +296,7 @@ public static function importBlocksFull($blocks, &$context) { $blockContent->save(); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $block['info'] . '"', 'ok'); + drush_log('Imported "' . $block['info'] . '"', 'ok'); } StructureSyncHelper::logMessage('Imported "' . $block['info'] . '"'); } @@ -319,7 +319,7 @@ public static function importBlocksFull($blocks, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Updated "' . $block['info'] . '"', 'ok'); + drush_log('Updated "' . $block['info'] . '"', 'ok'); } StructureSyncHelper::logMessage('Updated "' . $block['info'] . '"'); @@ -372,7 +372,7 @@ public static function importBlocksSafe($blocks, &$context) { $blockContent->save(); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $block['info'] . '"', 'ok'); + drush_log('Imported "' . $block['info'] . '"', 'ok'); } StructureSyncHelper::logMessage('Imported "' . $block['info'] . '"'); } @@ -390,7 +390,7 @@ public static function deleteBlocks(&$context) { ->delete($entities); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted all custom blocks', 'ok'); + drush_log('Deleted all custom blocks', 'ok'); } StructureSyncHelper::logMessage('Deleted all custom blocks'); } @@ -416,7 +416,7 @@ public static function importBlocksForce($blocks, &$context) { $blockContent->save(); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $block['info'] . '"', 'ok'); + drush_log('Imported "' . $block['info'] . '"', 'ok'); } StructureSyncHelper::logMessage('Imported "' . $block['info'] . '"'); } @@ -434,7 +434,7 @@ public static function blocksImportFinishedCallback($success, $results, $operati StructureSyncHelper::logMessage('Successfully imported custom blocks'); - $this->messenger()->addStatus(t('Successfully imported custom blocks')); + drupal_set_message(t('Successfully imported custom blocks')); } } diff --git a/src/Controller/MenuLinksController.php b/src/Controller/MenuLinksController.php index b91bd84ed575732851535e4607bd941e5a9ea871..354b4c16d098c41c5c8fca7d1026642d5e85610e 100755 --- a/src/Controller/MenuLinksController.php +++ b/src/Controller/MenuLinksController.php @@ -75,14 +75,14 @@ public function exportMenuLinks(array $form = NULL, FormStateInterface $form_sta ]; if (array_key_exists('drush', $form) && $form['drush'] === TRUE) { - \Drupal::logger('Exported "' . $menuLink->title->getValue()[0]['value'] . '" of menu "' . $menuLink->menu_name->getValue()[0]['value'] . '"', 'ok'); + drush_log('Exported "' . $menuLink->title->getValue()[0]['value'] . '" of menu "' . $menuLink->menu_name->getValue()[0]['value'] . '"', 'ok'); } StructureSyncHelper::logMessage('Exported "' . $menuLink->title->value . '" of menu "' . $menuLink->menu_name->value . '"'); } $this->config->set('menus', $customMenuLinks)->save(); - $this->messenger()->addStatus($this->t('The menu links have been successfully exported.')); + drupal_set_message($this->t('The menu links have been successfully exported.')); StructureSyncHelper::logMessage('Menu links exported'); } @@ -232,7 +232,7 @@ public static function deleteDeletedMenuLinks($menus, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted menu links that were not in config', 'ok'); + drush_log('Deleted menu links that were not in config', 'ok'); } StructureSyncHelper::logMessage('Deleted menu links that were not in config'); } @@ -341,7 +341,7 @@ public static function importMenuLinksFull($menus, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $menuLink['title'] . '" into ' . $menuLink['menu_name'], 'ok'); + drush_log('Imported "' . $menuLink['title'] . '" into ' . $menuLink['menu_name'], 'ok'); } StructureSyncHelper::logMessage('Imported "' . $menuLink['title'] . '" into ' . $menuLink['menu_name']); @@ -397,7 +397,7 @@ public static function importMenuLinksSafe($menus, &$context) { ])->save(); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu', 'ok'); + drush_log('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu', 'ok'); } StructureSyncHelper::logMessage('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu'); } @@ -415,7 +415,7 @@ public static function deleteMenuLinks(&$context) { ->delete($entities); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted all (content) menu links', 'ok'); + drush_log('Deleted all (content) menu links', 'ok'); } StructureSyncHelper::logMessage('Deleted all (content) menu links'); } @@ -442,7 +442,7 @@ public static function importMenuLinksForce($menus, &$context) { ])->save(); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu', 'ok'); + drush_log('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu', 'ok'); } StructureSyncHelper::logMessage('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu'); } @@ -460,7 +460,7 @@ public static function menuLinksImportFinishedCallback($success, $results, $oper StructureSyncHelper::logMessage('Successfully imported menu links'); - $this->messenger()->addStatus(t('Successfully imported menu links')); + drupal_set_message(t('Successfully imported menu links')); } } diff --git a/src/Controller/TaxonomiesController.php b/src/Controller/TaxonomiesController.php index ca77964a5b4be26b0dd4378876c006d523b51ef0..50aa309e152b2fdb9dd352f15ca7421f3f4a8382 100755 --- a/src/Controller/TaxonomiesController.php +++ b/src/Controller/TaxonomiesController.php @@ -54,7 +54,7 @@ public function exportTaxonomies(array $form = NULL, FormStateInterface $form_st if (!count($vocabulary_list)) { StructureSyncHelper::logMessage('No vocabularies available', 'warning'); - $this->messenger()->addWarning($this->t('No vocabularies selected/available')); + drupal_set_message($this->t('No vocabularies selected/available'), 'warning'); return; } @@ -144,12 +144,12 @@ public function exportTaxonomies(array $form = NULL, FormStateInterface $form_st $this->config->set('taxonomies.' . $vocabulary, $taxonomies)->save(); if (array_key_exists('drush', $form) && $form['drush'] === TRUE) { - \Drupal::logger('Exported ' . $vocabulary, 'ok'); + drush_log('Exported ' . $vocabulary, 'ok'); } StructureSyncHelper::logMessage('Exported ' . $vocabulary); } - $this->messenger()->addStatus($this->t('The taxonomies have been successfully exported.')); + drupal_set_message($this->t('The taxonomies have been successfully exported.')); StructureSyncHelper::logMessage('Taxonomies exported'); } @@ -311,7 +311,7 @@ public static function deleteDeletedTaxonomies($taxonomies, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted taxonomies that were not in config', 'ok'); + drush_log('Deleted taxonomies that were not in config', 'ok'); } StructureSyncHelper::logMessage('Deleted taxonomies that were not in config'); } @@ -465,7 +465,7 @@ public static function importTaxonomiesFull($taxonomies, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); + drush_log('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); } StructureSyncHelper::logMessage('Imported "' . $taxonomy['name'] . '" into ' . $vid); @@ -494,7 +494,7 @@ public static function importTaxonomiesFull($taxonomies, &$context) { StructureSyncHelper::logMessage('Flushing all caches'); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Flushing all caches', 'ok'); + drush_log('Flushing all caches', 'ok'); } drupal_flush_all_caches(); @@ -615,7 +615,7 @@ public static function importTaxonomiesSafe($taxonomies, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); + drush_log('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); } StructureSyncHelper::logMessage('Imported "' . $taxonomy['name'] . '" into ' . $vid); @@ -675,7 +675,7 @@ public static function deleteTaxonomies(&$context) { $controller->delete($entities); if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Deleted all taxonomies', 'ok'); + drush_log('Deleted all taxonomies', 'ok'); } StructureSyncHelper::logMessage('Deleted all taxonomies'); } @@ -782,7 +782,7 @@ public static function importTaxonomiesForce($taxonomies, &$context) { } if (array_key_exists('drush', $context) && $context['drush'] === TRUE) { - \Drupal::logger('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); + drush_log('Imported "' . $taxonomy['name'] . '" into ' . $vid, 'ok'); } StructureSyncHelper::logMessage('Imported "' . $taxonomy['name'] . '" into ' . $vid); @@ -819,7 +819,7 @@ public static function importTaxonomiesForce($taxonomies, &$context) { public static function taxonomiesImportFinishedCallback($success, $results, $operations) { StructureSyncHelper::logMessage('Successfully imported taxonomies'); - $this->messenger()->addStatus(t('Successfully imported taxonomies')); + drupal_set_message(t('Successfully imported taxonomies')); } } diff --git a/src/Form/TaxonomiesSyncForm.php b/src/Form/TaxonomiesSyncForm.php index 09072d4149875f2e90e83ba63d2433ed0f54d990..4536323944271a7a47a27a61c7a0990294e39ba0 100755 --- a/src/Form/TaxonomiesSyncForm.php +++ b/src/Form/TaxonomiesSyncForm.php @@ -141,7 +141,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $vocabulary_list_config[$voc] = $vocabulary_list[$voc]; if (!in_array($vocabulary_list_config[$voc], $vocabulary_list)) { - $this->messenger()->addWarning($this->t('Vocabulary "@voc" does not (yet) exist on the site', ['@voc' => $voc])); + drupal_set_message($this->t('Vocabulary "@voc" does not (yet) exist on the site', ['@voc' => $voc]), 'warning'); unset($vocabulary_list_config[$voc]); } diff --git a/structure_sync.drush.inc b/structure_sync.drush.inc index f7fa4cd224187bae442c3c1be47b71b38f7a9cc2..2af8f0f2cfe6f94255c50cbd9e8b54ff74dd4a0b 100755 --- a/structure_sync.drush.inc +++ b/structure_sync.drush.inc @@ -6,7 +6,7 @@ */ use Drupal\structure_sync\StructureSyncHelper; -use Drush\Drush; + /** * Implements hook_drush_command(). */ @@ -93,11 +93,11 @@ function drush_structure_sync_export_all() { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_export_taxonomies() { - Drush::output()->writeln('Exporting taxonomies...'); + drush_print('Exporting taxonomies...'); StructureSyncHelper::exportTaxonomies(['drush' => TRUE]); - \Drupal::logger('Successfully exported taxonomies', 'ok'); + drush_log('Successfully exported taxonomies', 'ok'); } /** @@ -107,7 +107,7 @@ function drush_structure_sync_export_taxonomies() { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_import_taxonomies($choice = FALSE) { - Drush::output()->writeln('Importing taxonomies...'); + drush_print('Importing taxonomies...'); $options = [ 'full' => 'Full', @@ -120,17 +120,17 @@ function drush_structure_sync_import_taxonomies($choice = FALSE) { } if ($choice && array_key_exists($choice, $options)) { - Drush::output()->writeln('Using "' . $options[$choice] . '" import style'); + drush_print('Using "' . $options[$choice] . '" import style'); StructureSyncHelper::importTaxonomies([ 'style' => $choice, 'drush' => TRUE, ]); - \Drupal::logger('Successfully imported taxonomies', 'ok'); + drush_log('Successfully imported taxonomies', 'ok'); } else { - \Drupal::logger('No choice made for import style on importing taxonomies', 'error'); + drush_log('No choice made for import style on importing taxonomies', 'error'); } } @@ -141,11 +141,11 @@ function drush_structure_sync_import_taxonomies($choice = FALSE) { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_export_blocks() { - Drush::output()->writeln('Exporting blocks...'); + drush_print('Exporting blocks...'); StructureSyncHelper::exportCustomBlocks(['drush' => TRUE]); - \Drupal::logger('Successfully exported blocks', 'ok'); + drush_log('Successfully exported blocks', 'ok'); } /** @@ -155,7 +155,7 @@ function drush_structure_sync_export_blocks() { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_import_blocks($choice = FALSE) { - Drush::output()->writeln('Importing blocks...'); + drush_print('Importing blocks...'); $options = [ 'full' => 'Full', @@ -168,17 +168,17 @@ function drush_structure_sync_import_blocks($choice = FALSE) { } if ($choice && array_key_exists($choice, $options)) { - Drush::output()->writeln('Using "' . $options[$choice] . '" import style'); + drush_print('Using "' . $options[$choice] . '" import style'); StructureSyncHelper::importCustomBlocks([ 'style' => $choice, 'drush' => TRUE, ]); - \Drupal::logger('Successfully imported custom blocks', 'ok'); + drush_log('Successfully imported custom blocks', 'ok'); } else { - \Drupal::logger('No choice made for import style on importing custom blocks', 'error'); + drush_log('No choice made for import style on importing custom blocks', 'error'); } } @@ -189,11 +189,11 @@ function drush_structure_sync_import_blocks($choice = FALSE) { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_export_menus() { - Drush::output()->writeln('Exporting menu links...'); + drush_print('Exporting menu links...'); StructureSyncHelper::exportMenuLinks(['drush' => TRUE]); - \Drupal::logger('Successfully exported menu links', 'ok'); + drush_log('Successfully exported menu links', 'ok'); } /** @@ -203,7 +203,7 @@ function drush_structure_sync_export_menus() { * drush_{module_name}_{item_id_for_command}() */ function drush_structure_sync_import_menus($choice = FALSE) { - Drush::output()->writeln('Importing menu links...'); + drush_print('Importing menu links...'); $options = [ 'full' => 'Full', @@ -216,16 +216,16 @@ function drush_structure_sync_import_menus($choice = FALSE) { } if ($choice && array_key_exists($choice, $options)) { - Drush::output()->writeln('Using "' . $options[$choice] . '" import style'); + drush_print('Using "' . $options[$choice] . '" import style'); StructureSyncHelper::importMenuLinks([ 'style' => $choice, 'drush' => TRUE, ]); - \Drupal::logger('Successfully imported menu links', 'ok'); + drush_log('Successfully imported menu links', 'ok'); } else { - \Drupal::logger('No choice made for import style on importing menu links', 'error'); + drush_log('No choice made for import style on importing menu links', 'error'); } } diff --git a/structure_sync.info.yml b/structure_sync.info.yml index b1a6b79d8d6cee60f6223647a90ddbf2976a7c11..af35835f54906bfb67117690b239e70b51f4f8a4 100755 --- a/structure_sync.info.yml +++ b/structure_sync.info.yml @@ -1,7 +1,6 @@ name: 'Structure Sync' description: 'Tool for syncing structural data that is stored as content.' core: 8.x -core_version_requirement: ^8 || ^9 configure: structure_sync.general.form dependencies: - drupal:taxonomy