Passed
Push — master ( c6afeb...a80cbd )
by Nic
02:33
created

OrderHistoryController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Dynamic\Foxy\Orders\Page;
4
5
use SilverStripe\ORM\PaginatedList;
6
use SilverStripe\Security\Security;
7
8
class OrderHistoryController extends \PageController
9
{
10
    /**
11
     * @var array
12
     */
13
    private static $allowed_actions = [
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
14
        'index',
15
    ];
16
17
    /**
18
     * @var PaginatedList
19
     */
20
    private $order_paginated_list;
21
22
    /**
23
     * @return bool|\SilverStripe\Control\HTTPResponse
24
     */
25
    public function checkMember()
26
    {
27
        if (Security::getCurrentUser()) {
28
            return true;
29
        } else {
30
            return Security::permissionFailure($this, _t(
31
                'AccountPage.CANNOTCONFIRMLOGGEDIN',
32
                'Please login to view this page.'
33
            ));
34
        }
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function index()
41
    {
42
        $this->checkMember();
43
44
        return [];
45
    }
46
47
    protected function setOrderPaginatedList()
48
    {
49
        $request = $this->getRequest();
50
        $orders = $this->data()->getOrderList();
51
        $start = ($request->getVar('start')) ? (int)$request->getVar('start') : 0;
52
        $records = PaginatedList::create($orders, $request);
53
        $records->setPageStart($start);
54
        $records->setPageLength($this->data()->PerPage);
55
56
        $this->extend('updateOrderPaginatedList', $records);
57
58
        $this->order_paginated_list = $records;
59
60
        return $this;
61
    }
62
63
    /**
64
     * @return PaginatedList
65
     */
66
    public function OrderPaginatedList()
67
    {
68
        if (!$this->order_paginated_list) {
69
            $this->setOrderPaginatedList();
70
        }
71
72
        return $this->order_paginated_list;
73
    }
74
}
75