/** * Makes the target path absolute as the adapters might have a different directory * * @param $path The path to convert * * @return string The absolute path * * @throws InvalidArgumentException In case the path is not writable or does not exist */ private function makeTargetAbsolute($path) { $directory = dirname($path); if (!is_dir($directory)) { throw new InvalidArgumentException(sprintf('Target path %s does not exist.', $directory)); } if (!is_writable($directory)) { throw new InvalidArgumentException(sprintf('Target path %s is not writeable.', $directory)); } return realpath($directory) . '/' . PathUtil::basename($path); }
/** * Locate the target for a string. * * @param String $resource * * @return String * * @throws TargetLocatorException */ private function locateString($context, $resource) { $url = parse_url($resource); if (isset($url['scheme']) && $this->isLocalFilesystem($url['scheme'])) { $resource = $url['path'] = $this->cleanupPath($url['path']); } // resource is a URI if (isset($url['scheme'])) { if ($this->isLocalFilesystem($url['scheme']) && $this->isFileInContext($url['path'], $context)) { return $this->getRelativePathFromContext($url['path'], $context); } return PathUtil::basename($resource); } // resource is a local path if ($this->isFileInContext($resource, $context)) { $resource = $this->cleanupPath($resource); return $this->getRelativePathFromContext($resource, $context); } else { return PathUtil::basename($resource); } }