1

On my D8 status report (admin/reports/status) I have warnings about an issue I might wish to ignore. Is there any way to suppress the warnings on that report page once I have seen them and made my decision?

If it matters, the warnings are about using a CDN instead of installing libraries locally with YAML Form, which produces a wall of ten yellow warning rows in my Status Report. If we decide to continue using the CDNs instead of installing, we'd like to not see those warnings taking over so much real estate on the Status Report page in the future.

  • I think this is reasonable request so I created this ticket (drupal.org/node/2825278) in the YAML Form module's issue queue. – jrockowitz Nov 7 '16 at 0:41
  • That's cool @jrockowitz, thank you. I'm watching the issue now. – Leraa Nov 7 '16 at 21:23
2

Unfortunately there is no hook_requirements_alter yet. As a workaround you may override system manager service which is responsible for invoking that hook.

src/SystemManager.php

namespace Drupal\example;

use Drupal\system\SystemManager as DefaultSystemManager;

/**
 * System Manager Service.
 */
class SystemManager extends DefaultSystemManager {

  /**
   * {@inheritdoc}
   */
  public function listRequirements() {
    // Suppress some unwanted warnings on Status report page.
    return array_filter(parent::listRequirements(), function ($requirement) {
      return $requirement['title'] != t('The message about CDN.');
    });
  }

}

src/ExampleServiceProvider.php

namespace Drupal\example;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;

/**
 * Overrides the system manager service to suppress some warnings.
 */
class ExampleServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function alter(ContainerBuilder $container) {
    $container->getDefinition('system.manager')
      ->setClass('Drupal\example\SystemManager');
  }

}
1

The controller for this route gathers up all the data reported by hook_requirements() from the SystemManager service method listRequirements() which is used to build its theme array.

There's no entry point into that process through the Drupal API's except through the theme layer. A module could evoke hook_preprocess_status_report() to alter the data in $requirements variable used to render the page.

This method would require you to alter the markup to provide UI element to capture the preference, store it, then use it to remove it from the $requirements array in future requests.

function MYMODULE_preprocess_status_report(&$variables) {
  // @TODO: processing logic for $variables['requirements']
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.