Issues (47)

src/SimpleJobsAdmin.php (7 issues)

1
<?php
2
3
namespace LeKoala\SimpleJobs;
4
5
use SilverStripe\ORM\DataList;
6
use SilverStripe\Admin\ModelAdmin;
7
use SilverStripe\Control\Director;
8
use SilverStripe\Forms\GridField\GridFieldConfig;
9
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
10
11
/**
12
 * Show all jobs and their results
13
 */
14
class SimpleJobsAdmin extends ModelAdmin
15
{
16
    /**
17
     * @var array<class-string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<class-string> at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in array<class-string>.
Loading history...
18
     */
19
    private static $managed_models = [
0 ignored issues
show
The private property $managed_models is not used, and could be removed.
Loading history...
20
        CronJob::class,
21
        CronTaskResult::class,
22
        SimpleTask::class,
23
    ];
24
25
    /**
26
     * @var string
27
     */
28
    private static $url_segment = 'jobs';
0 ignored issues
show
The private property $url_segment is not used, and could be removed.
Loading history...
29
30
    /**
31
     * @var string
32
     */
33
    private static $menu_title = 'Jobs';
0 ignored issues
show
The private property $menu_title is not used, and could be removed.
Loading history...
34
35
    /**
36
     * @var string
37
     */
38
    private static $menu_icon_class = "font-icon-checklist";
0 ignored issues
show
The private property $menu_icon_class is not used, and could be removed.
Loading history...
39
40
    /**
41
     * @var boolean
42
     */
43
    public $showImportForm = false;
44
45
    /**
46
     * @var int
47
     */
48
    private static $page_length = 50;
0 ignored issues
show
The private property $page_length is not used, and could be removed.
Loading history...
49
50
    private static $required_permission_codes = 'CMS_ACCESS_SimpleJobsAdmin';
0 ignored issues
show
The private property $required_permission_codes is not used, and could be removed.
Loading history...
51
52
    /**
53
     * @return DataList
54
     */
55
    public function getList()
56
    {
57
        if ($this->modelClass == CronJob::class) {
58
            CronJob::regenerateFromClasses(Director::isDev());
59
        }
60
        $list = parent::getList();
61
        return $list;
62
    }
63
64
    protected function getGridFieldConfig(): GridFieldConfig
65
    {
66
        $config = parent::getGridFieldConfig();
67
        $config->removeComponentsByType(GridFieldAddNewButton::class);
68
        return $config;
69
    }
70
}
71