@@ -2,41 +2,34 @@ public function executeBatch(sfWebRequest $request)
2
2
{
3
3
$request->checkCSRFProtection();
4
4
5
- if (!$ids = $request->getParameter('ids'))
6
- {
5
+ if (!$ids = $request->getParameter('ids')) {
7
6
$this->getUser()->setFlash('error', 'You must at least select one item.');
8
7
9
8
$this->redirect('@<?php echo $ this ->getUrlForAction ('list ' ) ?> ');
10
9
}
11
10
12
- if (!$action = $request->getParameter('batch_action'))
13
- {
11
+ if (!$action = $request->getParameter('batch_action')) {
14
12
$this->getUser()->setFlash('error', 'You must select an action to execute on the selected items.');
15
13
16
14
$this->redirect('@<?php echo $ this ->getUrlForAction ('list ' ) ?> ');
17
15
}
18
16
19
- if (!method_exists($this, $method = 'execute'.ucfirst($action)))
20
- {
17
+ if (!method_exists($this, $method = 'execute'.ucfirst($action))) {
21
18
throw new InvalidArgumentException(sprintf('You must create a "%s" method for action "%s"', $method, $action));
22
19
}
23
20
24
- if (!$this->getUser()->hasCredential($this->configuration->getCredentials($action)))
25
- {
21
+ if (!$this->getUser()->hasCredential($this->configuration->getCredentials($action))) {
26
22
$this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
27
23
}
28
24
29
25
$validator = new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => '<?php echo $ this ->getModelClass () ?> '));
30
- try
31
- {
26
+ try {
32
27
// validate ids
33
28
$ids = $validator->clean($ids);
34
29
35
30
// execute batch
36
31
$this->$method($request);
37
- }
38
- catch (sfValidatorError $e)
39
- {
32
+ } catch (sfValidatorError $e) {
40
33
$this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items as some items do not exist anymore.');
41
34
}
42
35
@@ -52,8 +45,7 @@ protected function executeBatchDelete(sfWebRequest $request)
52
45
->whereIn('<?php echo $ this ->getPrimaryKeys (true ) ?> ', $ids)
53
46
->execute();
54
47
55
- foreach ($records as $record)
56
- {
48
+ foreach ($records as $record) {
57
49
$this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $record)));
58
50
59
51
$record->delete();
0 commit comments