Eccube\Controller\Admin\Store\TemplateController::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);
        /** @var $Template \Eccube\Entity\Template */
        $Template = $app['eccube.repository.template']->find($id);
        if (!$Template) {
            $app->deleteMessage();
            return $app->redirect($app->url('admin_store_template'));
        }
        // デフォルトテンプレート
        if ($Template->isDefaultTemplate()) {
            $app->addError('admin.content.template.delete.default.error', 'admin');
            return $app->redirect($app->url('admin_store_template'));
        }
        // 設定中のテンプレート
        if ($app['config']['template_code'] === $Template->getCode()) {
            $app->addError('admin.content.template.delete.current.error', 'admin');
            return $app->redirect($app->url('admin_store_template'));
        }
        // テンプレートディレクトリの削除
        $config = $app['config'];
        $templateCode = $Template->getCode();
        $targetRealDir = $config['root_dir'] . '/app/template/' . $templateCode;
        $targetHtmlRealDir = $config['root_dir'] . '/html/template/' . $templateCode;
        $fs = new Filesystem();
        $fs->remove($targetRealDir);
        $fs->remove($targetHtmlRealDir);
        // テーブルからも削除
        $app['orm.em']->remove($Template);
        $app['orm.em']->flush();
        $app->addSuccess('admin.content.template.delete.complete', 'admin');
        return $app->redirect($app->url('admin_store_template'));
    }