Commit ca8bd51e authored by Gaus Surahman's avatar Gaus Surahman
Browse files

Issue #3253012 by gausarts: Added Drupal ^10 to track potential disruption.

parent b2eb4850
Loading
Loading
Loading
Loading
+16 −0
Changes for src/Blazy.php: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -512,6 +512,22 @@ class Blazy implements BlazyInterface {
    return \Drupal::hasService('request_stack') ? \Drupal::requestStack() : NULL;
  }

  /**
   * Returns a wrapper to pass tests, or DI where adding params is troublesome.
   */
  public static function pathResolver() {
    return \Drupal::hasService('extension.path.resolver') ? \Drupal::service('extension.path.resolver') : NULL;
  }

  /**
   * Returns a wrapper to pass tests, or DI where adding params is troublesome.
   *
   * @see https://www.drupal.org/node/2940031
   */
  public static function fileUrlGenerator() {
    return \Drupal::hasService('file_url_generator') ? \Drupal::service('file_url_generator') : NULL;
  }

  /**
   * Checks if Blazy is in CKEditor preview mode where no JS assets are loaded.
   */
+1 −1
Changes for src/BlazyAlter.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class BlazyAlter {
   */
  public static function ckeditorCssAlter(array &$css, Editor $editor) {
    if (self::isCkeditorApplicable($editor)) {
      $path = base_path() . drupal_get_path('module', 'blazy');
      $path = base_path() . Blazy::pathResolver()->getPath('module', 'blazy');
      $css[] = $path . '/css/components/blazy.media.css';
      $css[] = $path . '/css/components/blazy.preview.css';
      $css[] = $path . '/css/components/blazy.ratio.css';
+6 −4
Changes for src/BlazyUtil.php: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class BlazyUtil {
      // displayed via SRC attribute. Don't bother language prefixes for IMG.
      if ($public_path && strpos($normal_path, $public_path) !== FALSE) {
        $rel_path = str_replace($public_path, '', $normal_path);
        return file_build_uri($rel_path);
        return Blazy::streamWrapperManager()->normalizeUri($rel_path);
      }
    }
    return FALSE;
@@ -208,11 +208,13 @@ class BlazyUtil {
  }

  /**
   * A wrapper for file_url_transform_relative() to pass tests anywhere else.
   * A wrapper for ::transformRelative() to pass tests anywhere else.
   */
  public static function transformRelative($uri, $style = NULL) {
    $url = $style ? $style->buildUrl($uri) : file_create_url($uri);
    return file_url_transform_relative($url);
    $gen = Blazy::fileUrlGenerator();
    $url = $gen ? $gen->generateAbsoluteString($uri) : NULL;
    $url = $style ? $style->buildUrl($uri) : $url;
    return $gen ? $gen->transformRelative($url) : $url;
  }

  /**
+0 −14
Changes for tests/modules/blazy_test/blazy_test.module: 0 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -85,17 +85,3 @@ function blazy_test_config_schema_info_alter(array &$definitions) {
  $extra = ['thumbnail' => ''] + BlazyDefault::gridSettings();
  BlazyAlter::configSchemaInfoAlter($definitions, 'blazy_base', BlazyDefault::extendedSettings() + $extra);
}

/**
 * Attempts to satisfy the tests for <= D8.7.
 */
if (!function_exists('file_valid_uri')) {

  /**
   * Dummy function.
   */
  function file_valid_uri() {
    // Empty block to satisfy coder.
  }

}
+4 −3
Changes for tests/src/Traits/BlazyCreationTestTrait.php: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Drupal\field\Entity\FieldStorageConfig;
use Drupal\file\Entity\File;
use Drupal\filter\Entity\FilterFormat;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
use Drupal\blazy\Blazy;

/**
 * A Trait common for Blazy tests.
@@ -481,7 +482,7 @@ trait BlazyCreationTestTrait {

      if ($item instanceof ImageItem) {
        $this->uri = ($entity = $item->entity) && empty($item->uri) ? $entity->getFileUri() : $item->uri;
        $this->url = file_url_transform_relative(file_create_url($this->uri));
        $this->url = Blazy::fileUrlGenerator()->generateString($this->uri);
      }
    }

@@ -489,7 +490,7 @@ trait BlazyCreationTestTrait {
      $source = $this->root . '/core/misc/druplicon.png';
      $uri = 'public://test.png';
      $this->fileSystem->copy($source, $uri, FileSystemInterface::EXISTS_REPLACE);
      $this->url = file_create_url($uri);
      $this->url = Blazy::fileUrlGenerator()->generateAbsoluteString($uri);
    }

    $this->testItem = $this->image = $item;
@@ -508,7 +509,7 @@ trait BlazyCreationTestTrait {
  protected function getImagePath($is_dir = FALSE) {
    $path            = $this->root . '/sites/default/files/simpletest/' . $this->testPluginId;
    $item            = $this->createDummyImage();
    $this->dummyUrl  = file_url_transform_relative(file_create_url($this->dummyUri));
    $this->dummyUrl  = Blazy::fileUrlGenerator()->generateString($this->dummyUri);
    $this->dummyItem = $item;
    $this->dummyData = [
      'settings' => $this->getFormatterSettings(),
Loading