code/CMSBatchAction.php
public function response($successMessage, $status)
    {
        $count = 0;
        $errors = 0;

        foreach ($status as $k => $v) {
            switch ($k) {
                case 'error':
                    $errors += count($v);
                    break;
                case 'success':
                    $count += count($v);
                    break;
            }
        }

        $response = Controller::curr()->getResponse();

        if ($response) {
            $response->setStatusCode(
                200,
                sprintf($successMessage, $count, $errors)
            );
        }

        return json_encode($status);
    }
public function response($successMessage, $status)
    {
        $count = 0;
        $errors = 0;

        foreach ($status as $k => $v) {
            switch ($k) {
                case 'error':
                    $errors += count($v);
                    break;
                case 'success':
                    $count += count($v);
                    break;
            }
        }

        $response = Controller::curr()->getResponse();

        if ($response) {
            $response->setStatusCode(
                200,
                sprintf($successMessage, $count, $errors)
            );
        }

        return json_encode($status);
    }
public function response ( $ successMessage , $ status ) { $ count = 0 ; $ errors = 0 ; foreach ( $ status as $ k => $ v ) { switch ( $ k ) { case 'error' : $ errors += count ( $ v ) ; break ; case 'success' : $ count += count ( $ v ) ; break ; } } $ response = Controller :: curr ( ) -> getResponse ( ) ; if ( $ response ) { $ response -> setStatusCode ( 200 , sprintf ( $ successMessage , $ count , $ errors ) ) ; } return json_encode ( $ status ) ; }
Helper method for responding to a back action request
@param string $successMessage The message to return as a notification.
Can have up to two %d's in it. The first will be replaced by the number of successful
changes, the second by the number of failures
@param array $status A status array like batchactions builds. Should be
key => value pairs, the key can be any string: "error" indicates errors, anything
else indicates a type of success. The value is an array. We don't care what's in it,
we just use count($value) to find the number of items that succeeded or failed
@return string
Helper method for responding to a back action request