Commit 8d1c4c16 authored by catch's avatar catch
Browse files

Issue #3254245 by kim.pepper, Jeya sundhar, mrweiner, bakulahluwalia, Berdir,...

Issue #3254245 by kim.pepper, Jeya sundhar, mrweiner, bakulahluwalia, Berdir, catch, newaytech, Summit: TypeError: Argument 1 passed to Drupal\Core\File\FileUrlGenerator::generateString() must be of the type string, null given
parent 7af29a9e
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public function getFunctions() {
      new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
      new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
      new TwigFunction('link', [$this, 'getLink']),
      new TwigFunction('file_url', [$this->fileUrlGenerator, 'generateString']),
      new TwigFunction('file_url', [$this, 'getFileUrl']),
      new TwigFunction('attach_library', [$this, 'attachLibrary']),
      new TwigFunction('active_theme_path', [$this, 'getActiveThemePath']),
      new TwigFunction('active_theme', [$this, 'getActiveTheme']),
@@ -272,6 +272,22 @@ public function getLink($text, $url, $attributes = []) {
    return $build;
  }

  /**
   * Gets the file URL.
   *
   * @param string|null $uri
   *   The file URI.
   *
   * @return string
   *   The file URL.
   */
  public function getFileUrl(?string $uri) {
    if (is_null($uri)) {
      return NULL;
    }
    return $this->fileUrlGenerator->generateString($uri);
  }

  /**
   * Gets the name of the active theme.
   *
+1 −0
Original line number Diff line number Diff line
<div>file_url: {{ file_url('core/modules/system/tests/modules/twig_theme_test/twig_theme_test.js') }}</div>
<div>file_url: {{ file_url(undefined_variable) }}</div>