|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Port\Butler\Portals; |
|
4
|
|
|
|
|
5
|
|
|
use App\Port\Butler\Exceptions\WrongConfigurationsException; |
|
6
|
|
|
use Illuminate\Support\Facades\Config; |
|
7
|
|
|
use Illuminate\Support\Facades\File; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class PortButler. |
|
11
|
|
|
* |
|
12
|
|
|
* NOTE: You can access this Class functions with the facade [ModuleConfig]. |
|
13
|
|
|
* |
|
14
|
|
|
* @author Mahmoud Zalt <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class PortButler |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Get the containers namespace value from the containers config file |
|
21
|
|
|
* |
|
22
|
|
|
* @return string |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getContainersNamespace() |
|
25
|
|
|
{ |
|
26
|
|
|
return Config::get('hello.containers.namespace'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get the containers names |
|
31
|
|
|
* |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getContainersNames() |
|
35
|
|
|
{ |
|
36
|
|
|
$containersNames = []; |
|
37
|
|
|
|
|
38
|
|
|
foreach($this->getContainersPaths() as $containersPath){ |
|
39
|
|
|
$containersNames[] = basename($containersPath); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return $containersNames; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* get containers directories paths |
|
47
|
|
|
* |
|
48
|
|
|
* @return mixed |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getContainersPaths() |
|
51
|
|
|
{ |
|
52
|
|
|
return File::directories(app_path('Containers')); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* build the main service provider class namespace |
|
57
|
|
|
* |
|
58
|
|
|
* @param $containersNamespace |
|
59
|
|
|
* @param $containerName |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
public function buildMainServiceProvider($containersNamespace, $containerName) |
|
64
|
|
|
{ |
|
65
|
|
|
if($containerName != 'Port') { |
|
66
|
|
|
return $containersNamespace . "\\Containers\\" . $containerName . "\\Settings\\Providers\\" . $containerName . "ServiceProvider"; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return "App" . "\\Port" . "\\Provider\\Providers\\" . $containerName . "ServiceProvider"; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return mixed |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getLoginWebPageName() |
|
76
|
|
|
{ |
|
77
|
|
|
$loginPage = Config::get('hello.containers.login-page-name'); |
|
78
|
|
|
|
|
79
|
|
|
if (is_null($loginPage)) { |
|
80
|
|
|
throw new WrongConfigurationsException(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $loginPage; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|