Skip to content

Commit

Permalink
Consolidated quant_preprocess_page logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
kepol committed Jan 7, 2024
1 parent df7dda6 commit 1c9a80d
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ use Drupal\quant\QuantQueueFactory;
use Drupal\quant\Seed;
use Drupal\quant\Utility;

/**
* Implements hook_preprocess_page().
*/
function quant_preprocess_page(&$variables) {

// Add warning on Quant admin pages if queue factory is not set.
$current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo();
if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") {
\Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update <em>queue_service_quant_seed_worker</em> in your settings. See the <a href="https://docs.quantcdn.io/docs/integrations/drupal">Drupal docs</a> for setup information.'));
}
}

/**
* Implements hook_menu_local_tasks_alter().
*/
Expand Down Expand Up @@ -448,10 +436,15 @@ function quant_preprocess_page(&$variables) {
// Show the Quant page info block for non-admin pages if enabled.
$config = \Drupal::configFactory()->getEditable('quant.settings');
$enabled = $config->get('quant_show_page_info_block');

if ($enabled && !\Drupal::service('router.admin_context')->isAdminRoute()) {
$variables['page']['content']['#prefix'] = Utility::getPageInfo() . ($variables['page']['content']['#prefix'] ?? '');
}

// Add warning on Quant admin pages if queue factory is not set.
$current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo();
if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") {
\Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update <em>queue_service_quant_seed_worker</em> in your settings. See the <a href="https://docs.quantcdn.io/docs/integrations/drupal">Drupal docs</a> for setup information.'));
}
}

/**
Expand Down

0 comments on commit 1c9a80d

Please sign in to comment.