1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Symfony CMF package. |
5
|
|
|
* |
6
|
|
|
* (c) 2011-2017 Symfony CMF |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Admin; |
13
|
|
|
|
14
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
15
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
16
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
17
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
18
|
|
|
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; |
19
|
|
|
use Sonata\DoctrinePHPCRAdminBundle\Filter\NodeNameFilter; |
20
|
|
|
use Sonata\DoctrinePHPCRAdminBundle\Filter\StringFilter; |
21
|
|
|
use Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType; |
22
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @author Maximilian Berghoff <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class AssociationAdmin extends Admin |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var ManagerRegistry |
31
|
|
|
*/ |
32
|
|
|
private $managerRegistry; |
33
|
|
|
|
34
|
|
|
public function setManagerRegistry(ManagerRegistry $managerRegistry) |
35
|
|
|
{ |
36
|
|
|
$this->managerRegistry = $managerRegistry; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getExportFormats() |
40
|
|
|
{ |
41
|
|
|
return array(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function configureListFields(ListMapper $listMapper) |
45
|
|
|
{ |
46
|
|
|
$listMapper |
47
|
|
|
->addIdentifier('id') |
48
|
|
|
->add('title') |
49
|
|
|
; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function configureFormFields(FormMapper $formMapper) |
53
|
|
|
{ |
54
|
|
|
$formMapper |
55
|
|
|
->with('form.group_general') |
56
|
|
|
->add('name', TextType::class) |
57
|
|
|
->add('title', TextType::class) |
58
|
|
|
->add('parentDocument', TreeSelectType::class, [ |
59
|
|
|
'widget' => 'browser', |
60
|
|
|
'root_node' => $this->getRootPath(), |
61
|
|
|
]) |
62
|
|
|
->end() |
63
|
|
|
; |
64
|
|
|
|
65
|
|
|
$this->getFormBuilder()->get('parentDocument')->addModelTransformer(new DocumentToPathTransformer( |
66
|
|
|
$this->managerRegistry->getManagerForClass($this->getClass()) |
67
|
|
|
)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
71
|
|
|
{ |
72
|
|
|
$datagridMapper |
73
|
|
|
->add('title', StringFilter::class) |
74
|
|
|
->add('name', NodeNameFilter::class) |
75
|
|
|
; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|