Skip to content

Commit

Permalink
Don't rely on app()->joinPaths(), which is not available in Laravel 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Oct 22, 2023
1 parent f9b6742 commit d6219c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Support/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function __construct(string $domain, string $subdomain = null)

$this->namespace = DomainNamespaces::from($this->domain, $this->subdomain);

$this->path = str(app()->joinPaths(config('ddd.paths.domains'), $this->domainWithSubdomain))
->replace(['\\', '/'], DIRECTORY_SEPARATOR)
->toString();
$this->path = Path::join(config('ddd.paths.domains'), $this->domainWithSubdomain);
}

protected function getDomainBasePath()
Expand All @@ -76,7 +74,7 @@ public function path(string $path = null): string
->append('.php')
->toString();

return app()->joinPaths($this->path, $path);
return Path::join($this->path, $path);
}

public function relativePath(string $path = ''): string
Expand Down
20 changes: 20 additions & 0 deletions src/Support/Path.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Lunarstorm\LaravelDDD\Support;

class Path
{
public static function normalize($path)
{
return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
}

public static function join(...$parts)
{
$parts = array_map(function ($part) {
return trim(static::normalize($part), DIRECTORY_SEPARATOR);
}, $parts);

return implode(DIRECTORY_SEPARATOR, $parts);
}
}

0 comments on commit d6219c5

Please sign in to comment.