baseUrl example

$config = $this->config('system.file');
    $form['file_public_path'] = [
      '#type' => 'item',
      '#title' => $this->t('Public file system path'),
      '#markup' => PublicStream::basePath(),
      '#description' => $this->t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web. This must be changed in settings.php'),
    ];

    $form['file_public_base_url'] = [
      '#type' => 'item',
      '#title' => $this->t('Public file base URL'),
      '#markup' => PublicStream::baseUrl(),
      '#description' => $this->t('The base URL that will be used for public file URLs. This can be changed in settings.php'),
    ];

    $form['file_assets_path'] = [
      '#type' => 'item',
      '#title' => $this->t('Optimized assets file system path'),
      '#markup' => AssetsStream::basePath(),
      '#description' => $this->t('A local file system path where optimized assets files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web. This must be changed in settings.php'),
    ];

    $form['file_private_path'] = [
      

  public function getDirectoryPath() {
    return static::basePath();
  }

  /** * {@inheritdoc} */
  public function getExternalUrl() {
    $path = str_replace('\\', '/', $this->getTarget());
    return static::baseUrl() . '/' . UrlHelper::encodePath($path);
  }

  /** * Finds and returns the base URL for public://. * * Defaults to the current site's base URL plus directory path. * * Note that this static method is used by \Drupal\system\Form\FileSystemForm * so you should alter that form or substitute a different form if you change * the class providing the stream_wrapper.public service. * * @return string * The external base URL for public:// */

    function base_url($relativePath = '', ?string $scheme = null): string
    {
        $currentURI = Services::request()->getUri();

        assert($currentURI instanceof SiteURI);

        return $currentURI->baseUrl($relativePath$scheme);
    }
}

if (function_exists('current_url')) {
    /** * Returns the current full URL based on the Config\App settings and IncomingRequest. * * @param bool $returnObject True to return an object instead of a string * @param IncomingRequest|null $request A request to use when retrieving the path * * @return string|URI When returning string, the query and fragment parts are removed. * When returning URI, the query and fragment parts are preserved. */
parent::basePath($site_path)
    );
  }

  /** * {@inheritdoc} */
  public static function baseUrl(): string {
    $public_path = Settings::get('file_public_path', 'sites/default/files');
    $path = Settings::get('file_assets_path', $public_path);
    if ($path === $public_path) {
      $base_url = PublicStream::baseUrl();
    }
    else {
      $base_url = $GLOBALS['base_url'] . '/' . $path;
    }

    return $base_url;
  }

}
Home | Imprint | This part of the site doesn't use cookies.