-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThemeServiceProvider.php
More file actions
85 lines (70 loc) · 1.73 KB
/
ThemeServiceProvider.php
File metadata and controls
85 lines (70 loc) · 1.73 KB
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
<?php
namespace Apolune\Core;
use ReflectionClass;
abstract class ThemeServiceProvider extends AggregateServiceProvider
{
/**
* The paths that should be published.
*
* @var array
*/
protected $publish = [];
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
parent::register();
$directory = $this->directory();
foreach ($this->publish as $group => $paths) {
$locations = [];
array_walk($paths, function ($to, $from) use ($directory, &$locations) {
$from = sprintf("%s/%s", $directory, $from);
$locations[$from] = base_path($to);
});
$this->publishes($locations, $group);
}
}
/**
* Get the theme namespace.
*
* @return string
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* Register a view file namespace.
*
* @param string $path
* @return void
*/
protected function getViewsFrom($path)
{
$path = sprintf("%s/%s", $this->directory(), $path);
return $this->loadViewsFrom(realpath($path), 'theme');
}
/**
* Register a translation file namespace.
*
* @param string $path
* @return void
*/
protected function getTranslationsFrom($path)
{
$path = sprintf("%s/%s", $this->directory(), $path);
return $this->loadTranslationsFrom(realpath($path), 'theme');
}
/**
* Get the directory of the calling class.
*
* @return string
*/
private function directory()
{
return dirname((new \ReflectionClass($this))->getFileName());
}
}