59 return [self::SYS_TMP => [self::PATH =>
'']];
72 throw new \InvalidArgumentException(
'Unexpected value type.');
74 $defaultConfig = static::getDefaultConfig();
76 if (!is_array(
$row)) {
77 throw new \InvalidArgumentException(
'Unexpected value type.');
79 if (!isset($defaultConfig[
$type])) {
80 throw new \InvalidArgumentException(
"Unknown type: {$type}");
82 if (!isset(
$row[self::PATH]) && !isset(
$row[self::URL_PATH])) {
83 throw new \InvalidArgumentException(
"Missing required keys at: {$type}");
97 $this->root = $this->normalizePath($root);
98 $this->directories = static::getDefaultConfig();
99 $this->directories[
self::SYS_TMP] = [self::PATH => realpath(sys_get_temp_dir())];
102 foreach ($this->directories as
$code => $dir) {
103 foreach ([self::PATH, self::URL_PATH] as $key) {
111 foreach ($this->directories as
$code => $dir) {
112 $path = $this->normalizePath($dir[self::PATH]);
118 if (isset($dir[self::URL_PATH])) {
119 $this->assertUrlPath($dir[self::URL_PATH]);
130 private function normalizePath(
$path)
132 return str_replace(
'\\',
'/',
$path);
145 private function assertUrlPath($urlPath)
147 if (!preg_match(
'/^([a-z0-9_]+[a-z0-9\._]*(\/[a-z0-9_]+[a-z0-9\._]*)*)?$/', $urlPath)) {
148 throw new \InvalidArgumentException(
149 "URL path must be relative directory path in lowercase with '/' directory separator: '{$urlPath}'" 163 return $root . ($root &&
$path ?
'/' :
'') .
$path;
176 if (strpos(
$path,
'/') === 0) {
182 }
elseif (parse_url(
$path, PHP_URL_SCHEME) !==
null) {
209 $this->assertCode(
$code);
221 $this->assertCode(
$code);
222 if (!isset($this->directories[
$code][self::URL_PATH])) {
235 private function assertCode(
$code)
237 if (!isset($this->directories[
$code])) {
238 throw new \Magento\Framework\Exception\FileSystemException(
__construct($root, array $config=[])
elseif(isset( $params[ 'redirect_parent']))
static getDefaultConfig()