protected function evaluateResourcePath($requestedPath, $checkForExistence = true)
    {
        $requestPathParts = explode('://', $requestedPath, 2);
        if ($requestPathParts[0] !== self::SCHEME) {
            throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
        }

        if (!isset($requestPathParts[1])) {
            return false;
        }

        $resourceUriWithoutScheme = $requestPathParts[1];

        if (strpos($resourceUriWithoutScheme, '/') === false && preg_match('/^[0-9a-f]{40}$/i', $resourceUriWithoutScheme) === 1) {
            $resource = $this->resourceManager->getResourceBySha1($resourceUriWithoutScheme);
            return $this->resourceManager->getStreamByResource($resource);
        }

        list($packageName, $path) = explode('/', $resourceUriWithoutScheme, 2);

        try {
            $package = $this->packageManager->getPackage($packageName);
        } catch (\Neos\Flow\Package\Exception\UnknownPackageException $packageException) {
            throw new ResourceException(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $packageName), 1309269952, $packageException);
        }

        if (!$package instanceof FlowPackageInterface) {
            return false;
        }

        $resourceUri = Files::concatenatePaths([$package->getResourcesPath(), $path]);

        if ($checkForExistence === false || file_exists($resourceUri)) {
            return $resourceUri;
        }

        return false;
    }