-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTranslatableLabelController.php
More file actions
176 lines (163 loc) · 4.38 KB
/
Copy pathTranslatableLabelController.php
File metadata and controls
176 lines (163 loc) · 4.38 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
namespace Bigfoot\Bundle\CoreBundle\Controller;
use Bigfoot\Bundle\CoreBundle\Form\TranslatableLabelType;
use Bigfoot\Bundle\CoreBundle\Manager\TranslatableLabelManager;
use Doctrine\ORM\Query;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* TranslatableLabel controller.
*
* @Cache(maxage="0", smaxage="0", public="false")
* @Route("/translatable_label")
*/
class TranslatableLabelController extends CrudController
{
/**
* @return string
*/
protected function getName()
{
return 'admin_translatable_label';
}
/**
* @return string
*/
protected function getEntity()
{
return 'BigfootCoreBundle:TranslatableLabel';
}
/**
* @return array
*/
protected function getFields()
{
return array(
'category' => array(
'formatters' => array(
'trans'
),
'width' => '200px'
),
'name' => array(
'width' => '300px'
),
'value',
'editedAt' => array(
'formatters' => array(
'date'
),
'width' => '120px'
),
);
}
/**
* @return array
*/
protected function getFilters()
{
return array(
array(
'placeholder' => 'Categories',
'name' => 'category',
'type' => 'repositoryMethod',
'options' => array(
'method' => 'addCategoryFilter',
'choicesMethod' => 'getCategories'
)
),
array(
'placeholder' => 'Identifiant',
'name' => 'name',
'type' => 'search',
'options' => array(
'properties' => array(
'name',
)
)
),
array(
'placeholder' => 'Traduction',
'name' => 'search',
'type' => 'search',
'options' => array(
'properties' => array(
'value',
)
)
),
array(
'placeholder' => 'Domaine (pour les URLs)',
'name' => 'domain',
'type' => 'search',
'options' => array(
'properties' => array(
'domain',
)
)
),
);
}
/**
* @return string
*/
protected function getEntityLabelPlural()
{
return 'bigfoot_core.crud.controller.admin_translatable_label.entity.label_plural';
}
/**
* @return string
*/
protected function getFormType()
{
return TranslatableLabelType::class;
}
/**
* Lists all TranslatableLabel entities.
*
* @Route("/", name="admin_translatable_label")
* @param Request $request
* @return array
*/
public function indexAction(Request $request)
{
return $this->doIndex($request);
}
/**
* Displays a form to edit an existing TranslatableLabel entity.
*
* @Route("/{id}/edit", name="admin_translatable_label_edit")
*/
public function editAction(Request $request, $id)
{
return $this->doEdit($request, $id);
}
/**
* @param $id
* @return object
*/
protected function getFormEntity($id)
{
$entity = parent::getFormEntity($id);
if ($entity) {
$entity->setTranslatableLocale($this->container->getParameter('locale'));
$this->getEntityManager()->refresh($entity);
}
return $entity;
}
/**
* Post flush entity
*
* @param object $entity entity
* @param string $action
*/
protected function postFlush($entity, $action)
{
/** @var TranslatableLabelManager $labelManager */
$labelManager = $this->get('bigfoot_core.manager.translatable_label');
$labelManager->clearTranslationCache();
}
}