|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Sonata\AdminBundle\Admin\AbstractAdmin; |
|
6
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
|
7
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
|
8
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
|
9
|
|
|
use Sonata\Form\Type\CollectionType; |
|
10
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
11
|
|
|
use Sonata\AdminBundle\Route\RouteCollection; |
|
12
|
|
|
|
|
13
|
|
|
final class ModuleAdmin extends AbstractAdmin |
|
14
|
|
|
{ |
|
15
|
|
|
protected $datagridValues = [ |
|
16
|
|
|
'_page' => 1, |
|
17
|
|
|
'_sort_order' => 'ASC', |
|
18
|
|
|
'_sort_by' => 'position', |
|
19
|
|
|
]; |
|
20
|
|
|
|
|
21
|
|
|
protected function configureFormFields(FormMapper $formMapper) |
|
22
|
|
|
{ |
|
23
|
|
|
$formMapper->add('title', TextType::class); |
|
24
|
|
|
$formMapper->add('description', TextType::class); |
|
25
|
|
|
$formMapper->add('course'); |
|
26
|
|
|
$formMapper->add('lessons', CollectionType::class, [], [ |
|
27
|
|
|
'edit' => 'inline', |
|
28
|
|
|
'inline' => 'table', |
|
29
|
|
|
'sortable' => 'position', |
|
30
|
|
|
]); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
|
34
|
|
|
{ |
|
35
|
|
|
$datagridMapper->add('title'); |
|
36
|
|
|
$datagridMapper->add('course'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function configureListFields(ListMapper $listMapper) |
|
40
|
|
|
{ |
|
41
|
|
|
$listMapper->addIdentifier('title'); |
|
42
|
|
|
$listMapper->add('description'); |
|
43
|
|
|
$listMapper->add('course'); |
|
44
|
|
|
$listMapper->add('position'); |
|
45
|
|
|
$listMapper->add('_action', null, [ |
|
46
|
|
|
'actions' => [ |
|
47
|
|
|
'move' => [ |
|
48
|
|
|
'template' => '@PixSortableBehavior/Default/_sort_drag_drop.html.twig', |
|
49
|
|
|
'enable_top_bottom_buttons' => true, |
|
50
|
|
|
], |
|
51
|
|
|
], |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
protected function configureRoutes(RouteCollection $collection) |
|
56
|
|
|
{ |
|
57
|
|
|
$collection->add('move', $this->getRouterIdParameter().'/move/{position}'); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|