PaginatorTrait::getFieldsAssociations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Mgid\PaginationBundle\DependencyInjection;
4
5
use Mgid\Component\Pagination\Paginator;
6
7
trait PaginatorTrait
8
{
9
    protected Paginator $paginator;
10
11
    /**
12
     * @required
13
     *
14
     * @param Paginator $paginator
15
     */
16
    public function setPaginator(Paginator $paginator): void
17
    {
18
        $this->paginator = $paginator;
19
20
        $this->paginator->getMapping()->setAssociations($this->getFieldsAssociations());
21
        $this->paginator->getMapping()->getConstraint()->setOrders($this->getSortableFields());
22
        $this->paginator->getMapping()->getConstraint()->setFilters($this->getFilterableFields());
23
    }
24
25
    /**
26
     * @return string[]
27
     */
28
    protected function getSortableFields(): array
29
    {
30
        return [];
31
    }
32
33
    /**
34
     * @return string[]
35
     */
36
    protected function getFilterableFields(): array
37
    {
38
        return [];
39
    }
40
41
    /**
42
     * @return array<string,string>
43
     */
44
    protected function getFieldsAssociations(): array
45
    {
46
        return [];
47
    }
48
}
49