Eccube\Controller\Admin\Setting\Shop\PaymentController::delete PHP Method

delete() public method

public delete ( Application $app, Request $request, $id )
$app Eccube\Application
$request Symfony\Component\HttpFoundation\Request
    public function delete(Application $app, Request $request, $id)
    {
        $this->isTokenValid($app);
        $Payment = $app['eccube.repository.payment']->find($id);
        if (!$Payment) {
            $app->deleteMessage();
            return $app->redirect($app->url('admin_setting_shop_payment'));
        }
        $Payment->setDelFlg(Constant::ENABLED)->setRank(0);
        $app['orm.em']->persist($Payment);
        $rank = 1;
        $Payments = $app['eccube.repository.payment']->findBy(array('del_flg' => Constant::DISABLED), array('rank' => 'ASC'));
        foreach ($Payments as $Payment) {
            if ($Payment->getId() != $id) {
                $Payment->setRank($rank);
                $rank++;
            }
        }
        $app['orm.em']->flush();
        $event = new EventArgs(array('Payment' => $Payment), $request);
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_PAYMENT_DELETE_COMPLETE, $event);
        $app->addSuccess('admin.delete.complete', 'admin');
        return $app->redirect($app->url('admin_setting_shop_payment'));
    }