ProductCategoryController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A ProductPaginatedList() 0 15 3
1
<?php
2
3
namespace Dynamic\Products\Page;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\ORM\PaginatedList;
7
8
class ProductCategoryController extends \PageController
9
{
10
    /**
11
     * @param HTTPRequest|null $request
12
     * @return PaginatedList
13
     */
14
    public function ProductPaginatedList(HTTPRequest $request = null)
15
    {
16
        if (!$request instanceof HTTPRequest) {
17
            $request = $this->getRequest();
18
        }
19
        $recipes = $this->data()->getProductList();
20
        $start = ($request->getVar('start')) ? (int)$request->getVar('start') : 0;
21
        $records = PaginatedList::create($recipes, $request);
22
        $records->setPageStart($start);
23
        $records->setPageLength($this->data()->ProductsPerPage);
24
25
        // allow $records to be updated via extension
26
        $this->extend('updateProductPaginatedList', $records);
27
28
        return $records;
29
    }
30
}
31