1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Arrilot\Widgets\Misc; |
4
|
|
|
|
5
|
|
|
use Arrilot\Widgets\Contracts\ApplicationWrapperContract; |
6
|
|
|
use Closure; |
7
|
|
|
use Illuminate\Container\Container; |
8
|
|
|
|
9
|
|
|
class LaravelApplicationWrapper implements ApplicationWrapperContract |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Laravel application instance. |
13
|
|
|
*/ |
14
|
|
|
protected $app; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Constructor. |
18
|
|
|
*/ |
19
|
|
|
public function __construct() |
20
|
|
|
{ |
21
|
|
|
$this->app = Container::getInstance(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Wrapper around Cache::remember(). |
26
|
|
|
* |
27
|
|
|
* @param $key |
28
|
|
|
* @param $minutes |
29
|
|
|
* @param $tags |
30
|
|
|
* @param callable $callback |
31
|
|
|
* |
32
|
|
|
* @return mixed |
33
|
|
|
*/ |
34
|
|
|
public function cache($key, $minutes, $tags, Closure $callback) |
35
|
|
|
{ |
36
|
|
|
$cache = $this->app->make('cache'); |
37
|
|
|
|
38
|
|
|
if (method_exists($cache->getStore(), 'tags')) { |
39
|
|
|
$cache = $cache->tags($tags); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return $cache->remember($key, $minutes, $callback); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Wrapper around app()->call(). |
47
|
|
|
* |
48
|
|
|
* @param $method |
49
|
|
|
* @param array $params |
50
|
|
|
* |
51
|
|
|
* @return mixed |
52
|
|
|
*/ |
53
|
|
|
public function call($method, $params = []) |
54
|
|
|
{ |
55
|
|
|
return $this->app->call($method, $params); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get the specified configuration value. |
60
|
|
|
* |
61
|
|
|
* @param string $key |
62
|
|
|
* @param mixed $default |
63
|
|
|
* |
64
|
|
|
* @return mixed |
65
|
|
|
*/ |
66
|
|
|
public function config($key, $default = null) |
67
|
|
|
{ |
68
|
|
|
return $this->app->make('config')->get($key, $default); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Wrapper around app()->getNamespace(). |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getNamespace() |
77
|
|
|
{ |
78
|
|
|
return $this->app->getNamespace(); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Wrapper around app()->make(). |
83
|
|
|
* |
84
|
|
|
* @param string $abstract |
85
|
|
|
* @param array $parameters |
86
|
|
|
* |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
|
|
public function make($abstract, array $parameters = []) |
90
|
|
|
{ |
91
|
|
|
return $this->app->make($abstract, $parameters); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Wrapper around app()->get(). |
96
|
|
|
* |
97
|
|
|
* @param string $id |
98
|
|
|
* |
99
|
|
|
* @throws \Illuminate\Container\EntryNotFoundException |
100
|
|
|
* |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function get($id) |
104
|
|
|
{ |
105
|
|
|
return $this->app->get($id); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.