Eccube\Controller\Admin\Store\PluginController::download PHP Method

download() public method

認証キーダウンロード
public download ( Application $app, Request $request ) : RedirectResponse
$app Eccube\Application
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\RedirectResponse
    public function download(Application $app, Request $request)
    {
        $this->isTokenValid($app);
        $url = $app['config']['cacert_pem_url'];
        $curl = curl_init($url);
        $fileName = $app['config']['root_dir'] . '/app/config/eccube/' . $this->certFileName;
        $fp = fopen($fileName, 'w');
        if ($fp === false) {
            $app->addError('admin.plugin.download.pem.error', 'admin');
            $app->log('Cannot fopen to ' . $fileName, array(), Logger::ERROR);
            return $app->redirect($app->url('admin_store_authentication_setting'));
        }
        curl_setopt($curl, CURLOPT_FILE, $fp);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        $results = curl_exec($curl);
        $error = curl_error($curl);
        curl_close($curl);
        // curl で取得できない場合は file_get_contents で取得を試みる
        if ($results === false) {
            $file = file_get_contents($url);
            if ($file !== false) {
                fwrite($fp, $file);
            }
        }
        fclose($fp);
        $f = new Filesystem();
        if ($f->exists($fileName) && filesize($fileName) > 0) {
            $app->addSuccess('admin.plugin.download.pem.complete', 'admin');
        } else {
            $app->addError('admin.plugin.download.pem.error', 'admin');
            $app->log('curl_error: ' . $error, array(), Logger::ERROR);
        }
        return $app->redirect($app->url('admin_store_authentication_setting'));
    }