Completed
Push — master ( ab63ad...2d5693 )
by Nic
13s queued 10s
created

DiscountAdmin::getList()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 11
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Dynamic\Foxy\Discounts\Admin;
4
5
use Dynamic\Foxy\Discounts\Model\Discount;
6
use SilverStripe\Admin\ModelAdmin;
7
use SilverStripe\ORM\DataList;
8
use SilverStripe\Security\Member;
9
10
/**
11
 * Class DiscountAdmin
12
 * @package Dynamic\Foxy\Discounts\Admin
13
 */
14
class DiscountAdmin extends ModelAdmin
15
{
16
    /**
17
     * @var array
18
     */
19
    private static $managed_models = [
0 ignored issues
show
introduced by
The private property $managed_models is not used, and could be removed.
Loading history...
20
        Discount::class,
21
    ];
22
23
    /**
24
     * @var string
25
     */
26
    private static $url_segment = 'discounts';
0 ignored issues
show
introduced by
The private property $url_segment is not used, and could be removed.
Loading history...
27
28
    /**
29
     * @var string
30
     */
31
    private static $menu_title = 'Discounts';
0 ignored issues
show
introduced by
The private property $menu_title is not used, and could be removed.
Loading history...
32
33
    /**
34
     * @return DataList
35
     */
36
    public function getList()
37
    {
38
        $list = parent::getList();
39
40
        $excludeIDs = Member::get()->columnUnique('DiscountID');
41
42
        if (count($excludeIDs)) {
43
            $list = $list->exclude('ID', $excludeIDs);
44
        }
45
46
        return $list;
47
    }
48
}
49