PageMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Page\Mapper;
6
7
use Zend\Db\Adapter\Adapter;
8
use Zend\Db\Adapter\AdapterAwareInterface;
9
use Zend\Db\ResultSet\HydratingResultSet;
10
use Zend\Db\TableGateway\AbstractTableGateway;
11
12
class PageMapper extends AbstractTableGateway implements AdapterAwareInterface
13
{
14
    protected $table = 'page';
15
16
    public function setDbAdapter(Adapter $adapter)
17
    {
18
        throw new \Exception('Set DB adapter in constructor.', 400);
19
    }
20
21
    public function __construct(Adapter $adapter, HydratingResultSet $resultSet)
22
    {
23
        $this->resultSetPrototype = $resultSet;
24
        $this->adapter = $adapter;
25
        $this->initialize();
26
    }
27
28
    public function getPaginationSelect()
29
    {
30
        return $this->getSql()->select()->order(
31
            [
32
            'is_homepage' => 'desc',
33
            'created_at'  => 'desc',
34
            ]
35
        );
36
    }
37
38
    public function getActivePage($urlSlug)
39
    {
40
        return $this->select(['slug' => $urlSlug, 'is_active' => true]);
41
    }
42
}
43