Completed
Push — master ( 0fb6c2...a0d538 )
by Adam
19:02
created

ShipmentDataSet::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\ShipmentBundle\DataSet\Admin;
14
15
use Doctrine\ORM\QueryBuilder;
16
use WellCommerce\Bundle\CoreBundle\DataSet\AbstractDataSet;
17
use WellCommerce\Component\DataSet\Configurator\DataSetConfiguratorInterface;
18
19
/**
20
 * Class ShipmentDataSet
21
 *
22
 * @author Adam Piotrowski <[email protected]>
23
 */
24
class ShipmentDataSet extends AbstractDataSet
25
{
26
    public function getIdentifier(): string
27
    {
28
        return 'admin.shipment';
29
    }
30
    
31
    public function configureOptions(DataSetConfiguratorInterface $configurator)
32
    {
33
        $configurator->setColumns([
34
            'id'            => 'shipment.id',
35
            'orderNumber'   => 'orders.number',
36
            'guid'          => 'shipment.guid',
37
            'packageNumber' => 'shipment.packageNumber',
38
            'courier'       => 'shipment.courier',
39
            'createdAt'     => 'shipment.createdAt',
40
        ]);
41
        
42
        $configurator->setColumnTransformers([
43
            'createdAt' => $this->manager->createTransformer('date', ['format' => 'Y-m-d H:i:s']),
44
        ]);
45
    }
46
    
47
    protected function createQueryBuilder(): QueryBuilder
48
    {
49
        $queryBuilder = $this->repository->getQueryBuilder();
50
        $queryBuilder->leftJoin('shipment.order', 'orders');
51
        $queryBuilder->groupBy('shipment.id');
52
        
53
        return $queryBuilder;
54
    }
55
}
56