public function deleteBase(Request $request, $databox_id)
    {
        $databox = null;
        $success = false;
        $msg = $this->app->trans('An error occured');
        try {
            $databox = $this->findDataboxById($databox_id);

            if ($databox->get_record_amount() > 0) {
                $msg = $this->app->trans('admin::base: vider la base avant de la supprimer');
            } else {
                $databox->unmount_databox();
                $this->getApplicationBox()->write_databox_pic(
                    $this->app['media-alchemyst'],
                    $this->app['filesystem'],
                    $databox,
                    null,
                    \databox::PIC_PDF
                );
                $databox->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {

        }
        if (!$databox) {
            $this->app->abort(404, $this->app->trans('admin::base: databox not found', ['databox_id' => $databox_id]));
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg,
                'sbas_id' => $databox->get_sbas_id()
            ]);
        }

        $params = [
            'databox_id' => $databox->get_sbas_id(),
            'success'    => (int) $success,
        ];

        if ($databox->get_record_amount() > 0) {
            $params['error'] = 'databox-not-empty';
        }

        return $this->app->redirectPath('admin_database', $params);
    }
public function deleteBase(Request $request, $databox_id)
    {
        $databox = null;
        $success = false;
        $msg = $this->app->trans('An error occured');
        try {
            $databox = $this->findDataboxById($databox_id);

            if ($databox->get_record_amount() > 0) {
                $msg = $this->app->trans('admin::base: vider la base avant de la supprimer');
            } else {
                $databox->unmount_databox();
                $this->getApplicationBox()->write_databox_pic(
                    $this->app['media-alchemyst'],
                    $this->app['filesystem'],
                    $databox,
                    null,
                    \databox::PIC_PDF
                );
                $databox->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {

        }
        if (!$databox) {
            $this->app->abort(404, $this->app->trans('admin::base: databox not found', ['databox_id' => $databox_id]));
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg,
                'sbas_id' => $databox->get_sbas_id()
            ]);
        }

        $params = [
            'databox_id' => $databox->get_sbas_id(),
            'success'    => (int) $success,
        ];

        if ($databox->get_record_amount() > 0) {
            $params['error'] = 'databox-not-empty';
        }

        return $this->app->redirectPath('admin_database', $params);
    }
public function deleteBase ( Request $ request , $ databox_id ) { $ databox = null ; $ success = false ; $ msg = $ this -> app -> trans ( 'An error occured' ) ; try { $ databox = $ this -> findDataboxById ( $ databox_id ) ; if ( $ databox -> get_record_amount ( ) > 0 ) { $ msg = $ this -> app -> trans ( 'admin::base: vider la base avant de la supprimer' ) ; } else { $ databox -> unmount_databox ( ) ; $ this -> getApplicationBox ( ) -> write_databox_pic ( $ this -> app [ 'media-alchemyst' ] , $ this -> app [ 'filesystem' ] , $ databox , null , \ databox :: PIC_PDF ) ; $ databox -> delete ( ) ; $ success = true ; $ msg = $ this -> app -> trans ( 'Successful removal' ) ; } } catch ( \ Exception $ e ) { } if ( ! $ databox ) { $ this -> app -> abort ( 404 , $ this -> app -> trans ( 'admin::base: databox not found' , [ 'databox_id' => $ databox_id ] ) ) ; } if ( 'json' === $ request -> getRequestFormat ( ) ) { return $ this -> app -> json ( [ 'success' => $ success , 'msg' => $ msg , 'sbas_id' => $ databox -> get_sbas_id ( ) ] ) ; } $ params = [ 'databox_id' => $ databox -> get_sbas_id ( ) , 'success' => ( int ) $ success , ] ; if ( $ databox -> get_record_amount ( ) > 0 ) { $ params [ 'error' ] = 'databox-not-empty' ; } return $ this -> app -> redirectPath ( 'admin_database' , $ params ) ; }
Delete a databox

@param  Request $request    The current HTTP request
@param  integer $databox_id The requested databox
@return JsonResponse|RedirectResponse
Delete a databox