This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from LaraChimp/master
Improvements
- Loading branch information
Showing
6 changed files
with
110 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace LaraChimp\PineAnnotations\Concerns; | ||
|
||
use Illuminate\Console\DetectsApplicationNamespace; | ||
|
||
trait NamespaceToPathConvertable | ||
{ | ||
use DetectsApplicationNamespace; | ||
|
||
/** | ||
* Convert the given namespace to a file path. | ||
* | ||
* @param string $namespace | ||
* @param string $base | ||
* | ||
* @return string | ||
*/ | ||
public function getPathFromNamespace($namespace, $base = null) | ||
{ | ||
$appNamespace = $this->getAppNamespace(); | ||
|
||
// Remove the app namespace from the namespace if it is there | ||
if (substr($namespace, 0, strlen($appNamespace)) == $appNamespace) { | ||
$namespace = substr($namespace, strlen($appNamespace)); | ||
} | ||
$path = str_replace('\\', '/', trim($namespace, ' \\')); | ||
|
||
// trim and return the path | ||
return ($base ?: app_path()).'/'.$path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters