RecipeCategoryPageController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

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