Passed
Push — master ( 01c5da...60d466 )
by Jason
03:06 queued 01:31
created

src/Elements/ElementFileList.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Dynamic\Elements\FileList\Elements;
4
5
use DNADesign\Elemental\Models\BaseElement;
6
use Dynamic\Elements\FileList\Model\FileListObject;
7
use SilverStripe\ORM\FieldType\DBField;
8
9
class ElementFileList extends BaseElement
10
{
11
    /**
12
     * @var string
13
     */
14
    private static $icon = 'font-icon-block-file-list';
15
16
    /**
17
     * @var string
18
     */
19
    private static $singular_name = 'File List Element';
20
21
    /**
22
     * @var string
23
     */
24
    private static $plural_name = 'File List Elements';
25
26
    /**
27
     * @var string
28
     */
29
    private static $table_name = 'ElementFileList';
30
31
    /**
32
     * @var array
33
     */
34
    private static $has_many = [
35
        'Files' => FileListObject::class,
36
    ];
37
38
    /**
39
     * @var array
40
     */
41
    private static $owns = [
42
        'Files',
43
    ];
44
45
    /**
46
     * Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be
47
     * clickable and a GridFieldDetailForm will be used.
48
     *
49
     * @config
50
     * @var bool
51
     */
52
    private static $inline_editable = false;
53
54
    /**
55
     * @return DBHTMLText
0 ignored issues
show
The type Dynamic\Elements\FileList\Elements\DBHTMLText 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...
56
     */
57
    public function getSummary()
58
    {
59
        if ($this->Files()->count() == 1) {
60
            $label = ' file';
61
        } else {
62
            $label = ' files';
63
        }
64
        return DBField::create_field('HTMLText', $this->Files()->count() . $label)->Summary(20);
65
    }
66
67
    /**
68
     * @return array
69
     */
70
    protected function provideBlockSchema()
71
    {
72
        $blockSchema = parent::provideBlockSchema();
73
        $blockSchema['content'] = $this->getSummary();
74
        return $blockSchema;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getType()
81
    {
82
        return _t(__CLASS__.'.BlockType', 'File List');
83
    }
84
}
85