Passed
Push — master ( 2a4a9b...87d6cd )
by Jason
01:52
created

OrderHistoryController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
rs 10
1
<?php
2
3
namespace Dynamic\Foxy\Orders\Page;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\ORM\PaginatedList;
7
use SilverStripe\Security\Security;
8
9
class OrderHistoryController extends \PageController
10
{
11
    /**
12
     * @var array
13
     */
14
    private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
15
        'index',
16
    );
17
18
    /**
19
     * @return bool|\SilverStripe\Control\HTTPResponse
20
     */
21
    public function checkMember()
22
    {
23
        if (Security::getCurrentUser()) {
24
            return true;
25
        } else {
26
            return Security::permissionFailure($this, _t(
27
                'AccountPage.CANNOTCONFIRMLOGGEDIN',
28
                'Please login to view this page.'
29
            ));
30
        }
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function index()
37
    {
38
        $this->checkMember();
39
        return array();
40
    }
41
42
    /**
43
     * @param HTTPRequest|null $request
44
     * @return PaginatedList
45
     */
46
    public function OrderPaginatedList(HTTPRequest $request = null)
47
    {
48
        if (!$request instanceof HTTPRequest) {
49
            $request = $this->getRequest();
50
        }
51
        $orders = $this->data()->getOrderList();
52
        $start = ($request->getVar('start')) ? (int)$request->getVar('start') : 0;
53
        $records = PaginatedList::create($orders, $request);
54
        $records->setPageStart($start);
55
        $records->setPageLength($this->data()->PerPage);
56
57
        // allow $records to be updated via extension
58
        $this->extend('updateOrderPaginatedList', $records);
59
60
        return $records;
61
    }
62
}
63