فهرست منبع

Fixed problem with batch action confirmation label

Andrej Hudec 10 سال پیش
والد
کامیت
4624ec78aa
2فایلهای تغییر یافته به همراه2 افزوده شده و 6 حذف شده
  1. 1 1
      Controller/CRUDController.php
  2. 1 5
      Tests/Controller/CRUDControllerTest.php

+ 1 - 1
Controller/CRUDController.php

@@ -533,7 +533,7 @@ class CRUDController extends Controller
             true;
             true;
 
 
         if ($askConfirmation && $confirmation != 'ok') {
         if ($askConfirmation && $confirmation != 'ok') {
-            $actionLabel = $this->admin->trans($this->admin->getTranslationLabel($action, 'action'));
+            $actionLabel = $batchActions[$action]['label'];
 
 
             $formView = $datagrid->getForm()->createView();
             $formView = $datagrid->getForm()->createView();
 
 

+ 1 - 5
Tests/Controller/CRUDControllerTest.php

@@ -2727,11 +2727,6 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
             ->method('getBatchActions')
             ->method('getBatchActions')
             ->will($this->returnValue($batchActions));
             ->will($this->returnValue($batchActions));
 
 
-        $this->admin->expects($this->once())
-            ->method('getTranslationLabel')
-            ->with($this->equalTo('delete'), $this->equalTo('action'))
-            ->will($this->returnValue('delete_action'));
-
         $data = array('action'=>'delete', 'idx'=>array('123', '456'), 'all_elements'=>false);
         $data = array('action'=>'delete', 'idx'=>array('123', '456'), 'all_elements'=>false);
 
 
         $this->request->setMethod('POST');
         $this->request->setMethod('POST');
@@ -2767,6 +2762,7 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
         $this->assertInstanceOf('Symfony\Component\Form\FormView', $this->parameters['form']);
         $this->assertInstanceOf('Symfony\Component\Form\FormView', $this->parameters['form']);
         $this->assertEquals($data, $this->parameters['data']);
         $this->assertEquals($data, $this->parameters['data']);
         $this->assertEquals('csrf-token-123_sonata.batch', $this->parameters['csrf_token']);
         $this->assertEquals('csrf-token-123_sonata.batch', $this->parameters['csrf_token']);
+        $this->assertEquals('Foo Bar', $this->parameters['action_label']);
 
 
         $this->assertEquals(array(), $this->session->getFlashBag()->all());
         $this->assertEquals(array(), $this->session->getFlashBag()->all());
         $this->assertEquals('SonataAdminBundle:CRUD:batch_confirmation.html.twig', $this->template);
         $this->assertEquals('SonataAdminBundle:CRUD:batch_confirmation.html.twig', $this->template);