|
1
|
|
|
<?php namespace Anomaly\Streams\Platform\Asset\Command; |
|
2
|
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Addon\Theme\ThemeCollection; |
|
4
|
|
|
use Anomaly\Streams\Platform\Asset\Event\ThemeVariablesHaveLoaded; |
|
5
|
|
|
use Anomaly\Streams\Platform\Support\Collection; |
|
6
|
|
|
use Illuminate\Config\Repository; |
|
7
|
|
|
use Illuminate\Contracts\Events\Dispatcher; |
|
8
|
|
|
use Websemantics\Lcss2php\Lcss2php; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class LoadThemeVariables |
|
12
|
|
|
* |
|
13
|
|
|
* @link http://pyrocms.com/ |
|
14
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
|
15
|
|
|
* @author Ryan Thompson <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class LoadThemeVariables |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* The theme variables. |
|
22
|
|
|
* |
|
23
|
|
|
* @var Collection |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $variables; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* The default variables files. |
|
29
|
|
|
* |
|
30
|
|
|
* @var array |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $default = [ |
|
33
|
|
|
'resources/less/theme/variables.less', |
|
34
|
|
|
'resources/scss/theme/_variables.scss', |
|
35
|
|
|
]; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Create a new ThemeVariablesHaveLoaded instance. |
|
39
|
|
|
* |
|
40
|
|
|
* @param ThemeCollection $themes |
|
|
|
|
|
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(Collection $variables) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->variables = $variables; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Handle the command. |
|
49
|
|
|
* |
|
50
|
|
|
* @param Dispatcher $events |
|
51
|
|
|
* @param Repository $config |
|
52
|
|
|
* @param ThemeCollection $themes |
|
53
|
|
|
* @internal param Repository $config |
|
54
|
|
|
*/ |
|
55
|
|
|
public function handle(Dispatcher $events, Repository $config, ThemeCollection $themes) |
|
56
|
|
|
{ |
|
57
|
|
|
if (!$theme = $themes->current()) { |
|
58
|
|
|
return; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Look for a list of variables files theme configuration: |
|
63
|
|
|
* |
|
64
|
|
|
* 'variables' => env('THEME_VARIABLES', ['resources/less/theme/variables.less']), |
|
65
|
|
|
* |
|
66
|
|
|
* If none exist, use defaults. |
|
67
|
|
|
*/ |
|
68
|
|
|
$files = array_map( |
|
69
|
|
|
function ($file) use ($theme) { |
|
70
|
|
|
return $theme->getPath($file); |
|
71
|
|
|
}, |
|
72
|
|
|
$config->get($theme->getNamespace('config.variables'), $this->default) |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$variables = (new Lcss2php($files))->ignore([\Leafo\ScssPhp\Type::T_MAP, \Leafo\ScssPhp\Type::T_MIXIN]); |
|
76
|
|
|
|
|
77
|
|
|
foreach ($variables->all() as $key => $value) { |
|
78
|
|
|
$this->variables->put($key, $value); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$events->fire(new ThemeVariablesHaveLoaded($this->variables)); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.