getLocalPath example

 $target] = explode('://', $uri, 2);

    // Remove erroneous leading or trailing, forward-slashes and backslashes.     return trim($target, '\/');
  }

  /** * {@inheritdoc} */
  public function realpath() {
    return $this->getLocalPath();
  }

  /** * Returns the canonical absolute path of the URI, if possible. * * @param string $uri * (optional) The stream wrapper URI to be converted to a canonical * absolute path. This may point to a directory or another type of file. * * @return string|bool * If $uri is not set, returns the canonical absolute path of the URI * previously set by the * Drupal\Core\StreamWrapper\StreamWrapperInterface::setUri() function. * If $uri is set and valid for this class, returns its canonical absolute * path, as determined by the realpath() function. If $uri is set but not * valid, returns FALSE. */

  public function stream_open($uri$mode$options, &$opened_path) {
    if (!in_array($mode['r', 'rb', 'rt'])) {
      if ($options & STREAM_REPORT_ERRORS) {
        trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
      }
      return FALSE;
    }

    $this->uri = $uri;
    $path = $this->getLocalPath();
    $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path$mode) : @fopen($path$mode);

    if ($this->handle !== FALSE && ($options & STREAM_USE_PATH)) {
      $opened_path = $path;
    }

    return (bool) $this->handle;
  }

  /** * Returns the canonical absolute path of the URI, if possible. * * @param string $uri * (optional) The stream wrapper URI to be converted to a canonical * absolute path. This may point to a directory or another type of file. * * @return string|bool * If $uri is not set, returns the canonical absolute path of the URI * previously set by the * Drupal\Core\StreamWrapper\StreamWrapperInterface::setUri() function. * If $uri is set and valid for this class, returns its canonical absolute * path, as determined by the realpath() function. If $uri is set but not * valid, returns FALSE. * * @throws \BadMethodCallException * If the method is not implemented in the concrete driver class. * * @todo This method is called by ReadOnlyStream::stream_open on the abstract * class, and therefore should be defined as well on the abstract class to * prevent static analysis errors. In D11, consider changing it to an * abstract method. */
        // findSitePath().         $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
      }
    }
    return Settings::get('file_public_path', $site_path . '/files');
  }

  /** * {@inheritdoc} */
  protected function getLocalPath($uri = NULL) {
    $path = parent::getLocalPath($uri);
    if (!$path || str_starts_with($path, 'vfs://')) {
      return $path;
    }

    if (Settings::get('sa_core_2022_012_override') === TRUE) {
      return $path;
    }

    $private_path = Settings::get('file_private_path');
    if ($private_path) {
      $private_path = realpath($private_path);
      
Home | Imprint | This part of the site doesn't use cookies.