Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
115 lines (99 loc) · 2.22 KB

File metadata and controls

115 lines (99 loc) · 2.22 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
namespace Caffeinated\Modules\Repositories;
use Caffeinated\Modules\Contracts\RepositoryInterface;
use Illuminate\Config\Repository as Config;
use Illuminate\Filesystem\Filesystem;
abstract class Repository implements RepositoryInterface
{
/**
* @var \Illuminate\Config\Repository
*/
protected $config;
/**
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* @var string $path Path to the defined modules directory
*/
protected $path;
/**
* Constructor method.
*
* @param \Illuminate\Config\Repository $config
* @param \Illuminate\Filesystem\Filesystem $files
*/
public function __construct(Config $config, Filesystem $files)
{
$this->config = $config;
$this->files = $files;
}
/**
* Get all module basenames
*
* @return array
*/
protected function getAllBasenames()
{
$path = $this->getPath();
try {
$collection = collect($this->files->directories($path));
$basenames = $collection->map(function($item, $key) {
return basename($item);
});
return $basenames;
} catch (\InvalidArgumentException $e) {
return collect(array());
}
}
/**
* Get modules path.
*
* @return string
*/
public function getPath()
{
return $this->path ?: $this->config->get('modules.path');
}
/**
* Set modules path in "RunTime" mode.
*
* @param string $path
* @return object $this
*/
public function setPath($path)
{
$this->path = $path;
return $this;
}
/**
* Get path for the specified module.
*
* @param string $slug
* @return string
*/
public function getModulePath($slug)
{
$module = studly_case($slug);
return $this->getPath()."/{$module}/";
}
/**
* Get path of module manifest file.
*
* @param string $module
* @return string
*/
protected function getManifestPath($slug)
{
return $this->getModulePath($slug).'module.json';
}
/**
* Get modules namespace.
*
* @return string
*/
public function getNamespace()
{
return rtrim($this->config->get('modules.namespace'), '/\\');
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.