|
8 | 8 | use Arrilot\Widgets\Misc\InvalidWidgetClassException; |
9 | 9 | use Arrilot\Widgets\Misc\ViewExpressionTrait; |
10 | 10 | use Arrilot\Widgets\WidgetId; |
| 11 | +use Illuminate\Support\Str; |
11 | 12 |
|
12 | 13 | abstract class AbstractWidgetFactory |
13 | 14 | { |
@@ -115,12 +116,21 @@ protected function instantiateWidget(array $params = []) |
115 | 116 | { |
116 | 117 | WidgetId::increment(); |
117 | 118 |
|
118 | | - $this->widgetName = $this->parseFullWidgetNameFromString(array_shift($params)); |
| 119 | + $str = array_shift($params); |
| 120 | + |
| 121 | + if (preg_match('#^(.*?)::(.*?)$#', $str, $m)) { |
| 122 | + $rootNamespace = $this->app->get('arrilot.widget-namespaces')->getNamespace($m[1]); |
| 123 | + $str = $m[2]; |
| 124 | + } |
| 125 | + |
| 126 | + $this->widgetName = $this->parseFullWidgetNameFromString($str); |
119 | 127 | $this->widgetFullParams = $params; |
120 | 128 | $this->widgetConfig = (array) array_shift($params); |
121 | 129 | $this->widgetParams = $params; |
122 | 130 |
|
123 | | - $rootNamespace = $this->app->config('laravel-widgets.default_namespace', $this->app->getNamespace().'Widgets'); |
| 131 | + if (!isset($rootNamespace)) { |
| 132 | + $rootNamespace = $this->app->config('laravel-widgets.default_namespace', $this->app->getNamespace().'Widgets'); |
| 133 | + } |
124 | 134 |
|
125 | 135 | $fqcn = $rootNamespace.'\\'.$this->widgetName; |
126 | 136 | $widgetClass = class_exists($fqcn) ? $fqcn : $this->widgetName; |
@@ -149,7 +159,7 @@ protected function instantiateWidget(array $params = []) |
149 | 159 | */ |
150 | 160 | protected function parseFullWidgetNameFromString($widgetName) |
151 | 161 | { |
152 | | - return studly_case(str_replace('.', '\\_', $widgetName)); |
| 162 | + return Str::studly(str_replace('.', '\\_', $widgetName)); |
153 | 163 | } |
154 | 164 |
|
155 | 165 | /** |
|
0 commit comments