-
Notifications
You must be signed in to change notification settings - Fork 1
/
SyliusAdminOrder.php
83 lines (83 loc) · 3.06 KB
/
SyliusAdminOrder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* This code is generated by the config converter under https://github.com/mamazu/grid-config-converter
* Feel free to modify the code as you see fit.
*/
use Sylius\Bundle\GridBundle\Grid\AbstractGrid;
use Sylius\Bundle\GridBundle\Builder\Filter\Filter;
use Sylius\Bundle\GridBundle\Builder\Field\Field;
use Sylius\Bundle\GridBundle\Builder\GridBuilderInterface;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\MainActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\ItemActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\BulkActionGroup;
use Sylius\Bundle\GridBundle\Config\GridConfig;
use Sylius\Bundle\GridBundle\Builder\GridBuilder;
use Sylius\Bundle\GridBundle\Builder\Action\Action;
use Sylius\Bundle\GridBundle\Builder\Action\ShowAction;
use Sylius\Bundle\GridBundle\Builder\Action\UpdateAction;
use Sylius\Bundle\GridBundle\Builder\Action\DeleteAction;
use Sylius\Bundle\GridBundle\Builder\Field\DateTimeField;
use Sylius\Bundle\GridBundle\Builder\Field\StringField;
use Sylius\Bundle\GridBundle\Builder\Field\TwigField;
class SyliusAdminOrder extends AbstractGrid
{
public static function getName() : string
{
return 'sylius_admin_order';
}
public static function getResourceClass() : string
{
return '%sylius.model.order.class%';
}
public function buildGrid(GridBuilderInterface $gridBuilder) : void
{
$gridBuilder
->setDriver('doctrine/orm')
->setRepositoryMethod('createListQueryBuilder')
->setDriverOption('class', '%sylius.model.order.class%')
->addOrderBy('number', 'desc')
->setLimits([
30,
12,
48,
])
->addField(
DateTimeField::create('date')
->setLabel('sylius.ui.date')
->setPath('checkoutCompletedAt')
->setSortable(true, 'checkoutCompletedAt')
->setOptions([
'format' => 'd-m-Y H:i:s',
])
)
->addField(
TwigField::create('number', '@SyliusAdmin/Order/Grid/Field/number.html.twig')
->setLabel('sylius.ui.number')
->setPath('.')
->setSortable(true)
->setOptions([
'template' => '@SyliusAdmin/Order/Grid/Field/number.html.twig',
])
)
->addFilter(
Filter::create('number', 'string')
->setLabel('sylius.ui.number')
)
->addFilter(
Filter::create('shipping_method', 'entity')
->setLabel('sylius.ui.shipping_method')
->setOptions([
'fields' => [
'shipments.method',
],
])
->setFormOptions([
'class' => '%sylius.model.shipping_method.class%',
])
)
->addActionGroup(
ItemActionGroup::create(ShowAction::create())
)
;
}
}