Passed
Push — master ( 658575...3c4def )
by Jonathan
14:06
created

RelatedlistWidget::placeholder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Uccello\Core\Widgets;
4
5
use Arrilot\Widgets\AbstractWidget;
0 ignored issues
show
Bug introduced by
The type Arrilot\Widgets\AbstractWidget was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class RelatedlistWidget extends AbstractWidget
8
{
9
    /**
10
     * The configuration array.
11
     *
12
     * @var array
13
     */
14
    protected $config = [ ];
15
16
    public function placeholder()
17
    {
18
        return 'Loading...';
19
    }
20
21
    /**
22
     * Treat this method as a controller action.
23
     * Return view() or other content to display.
24
     */
25
    public function run()
26
    {
27
        // Get module
28
        $module = ucmodule($this->config['module']);
29
30
        // Get record
31
        $modelClass = $module->model_class;
0 ignored issues
show
Bug introduced by
The property model_class does not seem to exist on Uccello\Core\Models\Module. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
32
        $record = $modelClass::find($this->config['record_id']);
33
34
        return view('uccello::widgets.relatedlist', [
35
            'config' => $this->config,
36
            'domain' => ucdomain($this->config['domain']),
37
            'module' => $module,
38
            'data' => (object) $this->config['data'],
39
            'record' => $record,
40
            'label' => $this->config['data']->label ?? $this->config['labelForTranslation'],
41
        ]);
42
    }
43
}
44