Commit 9b8a258c authored by David Suissa's avatar David Suissa
Browse files

Issue #3518123 by dydave: Refactored method 'flushJsCss' with...

Issue #3518123 by dydave: Refactored method 'flushJsCss' with 'backwardsCompatibleCall' to support deprecated '_drupal_flush_css_js' for versions below core:10.2.
parent 4cbcb8d2
Loading
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\admin_toolbar_tools\Controller;

use Drupal\Component\Utility\DeprecationHelper;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -146,6 +147,7 @@ class ToolbarController extends ControllerBase {
    $instance->cssCollectionOptimizer = $container->get('asset.css.collection_optimizer');
    $instance->jsCollectionOptimizer = $container->get('asset.js.collection_optimizer');

    // @todo Remove deprecated code when support for core:10.2 is dropped.
    if (floatval(\Drupal::VERSION) >= 10.2) {
      $instance->assetQueryString = $container->get('asset.query_string');
    }
@@ -191,14 +193,9 @@ class ToolbarController extends ControllerBase {
    $this->cssCollectionOptimizer->deleteAll();
    $this->jsCollectionOptimizer->deleteAll();

    // @todo Remove once Core versions below 10.2.x are not supported anymore.
    if (floatval(\Drupal::VERSION) < 10.2) {
    // @todo Remove deprecated code when support for core:10.2 is dropped.
    // @phpstan-ignore function.notFound
      _drupal_flush_css_js();
    }
    else {
      $this->assetQueryString->reset();
    }
    DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => $this->assetQueryString->reset(), fn() => _drupal_flush_css_js());
    $this->messenger()->addMessage($this->t('CSS and JavaScript cache cleared.'));
    return new RedirectResponse($this->reloadPage());
  }
+9 −3
Original line number Diff line number Diff line
@@ -6,16 +6,22 @@ parameters:
    # Until a better solution can be found for hook implementations, it is
    # easier to ignore these errors. They are caused by conflicts with PHPCS
    # preventing from adding 'param' and 'return' for hook implementations.
    -
      message: '#Function admin_toolbar_[a-zA-Z0-9\\_]+\(\) has no return type specified\.#'
      paths:
        - *.install
        - *.module
    -
      message: '#Function admin_toolbar_[a-zA-Z0-9\\_]+\(\) has parameter \$[a-zA-Z0-9\\_]+ with no type specified\.#'
      paths:
        # - *.install
        - *.module
    -
      message: '#Function admin_toolbar_[a-zA-Z0-9\\_]+\(\) has parameter \$[a-zA-Z0-9\\_]+ with no value type specified in iterable type [a-zA-Z0-9\\_]+\.#'
      paths:
        - admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module
    -
      message: '#Function admin_toolbar_[a-zA-Z0-9\\_]+\(\) has no return type specified\.#'
      message: "#^Unable to resolve the template type Deprecated in call to method static method Drupal\\\\Component\\\\Utility\\\\DeprecationHelper\\:\\:backwardsCompatibleCall\\(\\)#"
      # count: 1
      paths:
        - *.install
        - *.module
        - admin_toolbar_tools/src/Controller/ToolbarController.php