Exemple #1
0
 public function testClear()
 {
     file_put_contents($this->app['config']['root_dir'] . '/app/cache/.dummykeep', 'test');
     // 'doctrine', 'profiler', 'twig' ディレクトリを削除
     Cache::clear($this->app, false);
     $finder = new Finder();
     $iterator = $finder->ignoreDotFiles(false)->in($this->app['config']['root_dir'] . '/app/cache')->files();
     foreach ($iterator as $fileinfo) {
         $this->assertStringEndsWith('keep', $fileinfo->getPathname(), 'keep しか存在しないはず');
     }
     $this->assertTrue($this->root->hasChild('app/cache/.gitkeep'), '.gitkeep は存在するはず');
     $this->assertTrue($this->root->hasChild('app/cache/.dummykeep'), '.dummykeep は存在するはず');
 }
Exemple #2
0
 public function index(Application $app, Request $request)
 {
     $form = $app->form()->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             switch ($request->get('mode')) {
                 case 'twig':
                     // Twigキャッシュクリア
                     Cache::clear($app, false, true);
                     $app->addSuccess('admin.content.twig.cache.save.complete', 'admin');
                     break;
                 default:
                     break;
             }
         }
     }
     return $app->render('Content/cache.twig', array('form' => $form->createView()));
 }
Exemple #3
0
 public function delete(Application $app, Request $request, $id)
 {
     $this->isTokenValid($app);
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $Block = $app['eccube.repository.block']->findOneBy(array('id' => $id, 'DeviceType' => $DeviceType));
     if (!$Block) {
         $app->deleteMessage();
         return $app->redirect($app->url('admin_content_block'));
     }
     // ユーザーが作ったブロックのみ削除する
     // テンプレートが変更されていた場合、DBからはブロック削除されるがtwigファイルは残る
     if ($Block->getDeletableFlg() > 0) {
         $tplDir = $app['config']['block_realdir'];
         $file = $tplDir . '/' . $Block->getFileName() . '.twig';
         $fs = new Filesystem();
         if ($fs->exists($file)) {
             $fs->remove($file);
         }
         $app['orm.em']->remove($Block);
         $app['orm.em']->flush();
         $event = new EventArgs(array('Block' => $Block), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_BLOCK_DELETE_COMPLETE, $event);
         $app->addSuccess('admin.delete.complete', 'admin');
         \Eccube\Util\Cache::clear($app, false);
     }
     return $app->redirect($app->url('admin_content_block'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     \Eccube\Util\Cache::clear($this->app, $input->getOption('all'));
     $output->writeln(sprintf("%s <info>success</info>", 'cache:clear'));
 }
 /**
  * オーナーズブラグインインストール、アップデート
  *
  * @param Application $app
  * @param Request $request
  * @param $action
  * @param $id
  * @param $version
  */
 public function upgrade(Application $app, Request $request, $action, $id, $version)
 {
     $BaseInfo = $app['eccube.repository.base_info']->get();
     $authKey = $BaseInfo->getAuthenticationKey();
     $message = '';
     if (!is_null($authKey)) {
         // オーナーズストア通信
         $url = $app['config']['owners_store_url'] . '?method=download&product_id=' . $id;
         list($json, $httpHeader) = $this->getRequestApi($request, $authKey, $url);
         if ($json === false) {
             // 接続失敗時
             $message = $this->getResponseErrorMessage($httpHeader);
         } else {
             // 接続成功時
             $data = json_decode($json, true);
             if (isset($data['success'])) {
                 $success = $data['success'];
                 if ($success == '1') {
                     $tmpDir = null;
                     try {
                         $service = $app['eccube.service.plugin'];
                         $item = $data['item'];
                         $file = base64_decode($item['data']);
                         $extension = pathinfo($item['file_name'], PATHINFO_EXTENSION);
                         $tmpDir = $service->createTempDir();
                         $tmpFile = sha1(Str::random(32)) . '.' . $extension;
                         // ファイル作成
                         $fs = new Filesystem();
                         $fs->dumpFile($tmpDir . '/' . $tmpFile, $file);
                         if ($action == 'install') {
                             $service->install($tmpDir . '/' . $tmpFile, $id);
                             $app->addSuccess('admin.plugin.install.complete', 'admin');
                         } else {
                             if ($action == 'update') {
                                 $Plugin = $app['eccube.repository.plugin']->findOneBy(array('source' => $id));
                                 $service->update($Plugin, $tmpDir . '/' . $tmpFile);
                                 $app->addSuccess('admin.plugin.update.complete', 'admin');
                                 Cache::clear($app, false);
                             }
                         }
                         $fs = new Filesystem();
                         $fs->remove($tmpDir);
                         // ダウンロード完了通知処理(正常終了時)
                         $url = $app['config']['owners_store_url'] . '?method=commit&product_id=' . $id . '&status=1&version=' . $version;
                         $this->getRequestApi($request, $authKey, $url);
                         return $app->redirect($app->url('admin_store_plugin'));
                     } catch (PluginException $e) {
                         if (!empty($tmpDir) && file_exists($tmpDir)) {
                             $fs = new Filesystem();
                             $fs->remove($tmpDir);
                         }
                         $message = $e->getMessage();
                     }
                 } else {
                     $message = $data['error_code'] . ' : ' . $data['error_message'];
                 }
             } else {
                 $message = "EC-CUBEオーナーズストアにエラーが発生しています。";
             }
         }
     }
     // ダウンロード完了通知処理(エラー発生時)
     $url = $app['config']['owners_store_url'] . '?method=commit&product_id=' . $id . '&status=0&version=' . $version . '&message=' . urlencode($message);
     $this->getRequestApi($request, $authKey, $url);
     $app->addError($message, 'admin');
     return $app->redirect($app->url('admin_store_plugin_owners_install'));
 }
 /**
  * ブロックを削除
  *
  * @param $app
  * @throws \Exception
  */
 private function removeBlock($app)
 {
     $file = new Filesystem();
     $file->remove($app['config']['block_realdir'] . '/' . $this->blockFileName . '.twig');
     // Blockの取得(file_nameはアプリケーションの仕組み上必ずユニーク)
     /** @var \Eccube\Entity\Block $Block */
     $Block = $app['eccube.repository.block']->findOneBy(array('file_name' => $this->blockFileName));
     if ($Block) {
         $em = $app['orm.em'];
         $em->getConnection()->beginTransaction();
         try {
             // BlockPositionの削除
             $blockPositions = $Block->getBlockPositions();
             /** @var \Eccube\Entity\BlockPosition $BlockPosition */
             foreach ($blockPositions as $BlockPosition) {
                 $Block->removeBlockPosition($BlockPosition);
                 $em->remove($BlockPosition);
             }
             // Blockの削除
             $em->remove($Block);
             $em->flush();
             $em->getConnection()->commit();
         } catch (\Exception $e) {
             $em->getConnection()->rollback();
             throw $e;
         }
     }
     Cache::clear($app, false);
 }
Exemple #7
0
 public function delete(Application $app, $id)
 {
     $this->isTokenValid($app);
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $Block = $app['eccube.repository.block']->findOrCreate($id, $DeviceType);
     // ユーザーが作ったブロックのみ削除する
     // テンプレートが変更されていた場合、DBからはブロック削除されるがtwigファイルは残る
     if ($Block->getDeletableFlg() > 0) {
         $tplDir = $app['config']['block_realdir'];
         $file = $tplDir . '/' . $Block->getFileName() . '.twig';
         $fs = new Filesystem();
         if ($fs->exists($file)) {
             $fs->remove($file);
         }
         $app['orm.em']->remove($Block);
         $app['orm.em']->flush();
         $app->addSuccess('admin.delete.complete', 'admin');
         \Eccube\Util\Cache::clear($app, false);
     }
     return $app->redirect($app->url('admin_content_block'));
 }
 /**
  * マイグレーションを実行し, 完了画面を表示させる
  *
  * @param InstallApplication $app
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function migration_end(InstallApplication $app, Request $request)
 {
     $this->doMigrate();
     $config_app = new \Eccube\Application();
     // install用のappだとconfigが取れないので
     $config_app->initialize();
     $config_app->boot();
     \Eccube\Util\Cache::clear($config_app, true);
     return $app['twig']->render('migration_end.twig');
 }
Exemple #9
0
 public function update(\Eccube\Entity\Plugin $plugin, $path)
 {
     $pluginBaseDir = null;
     $tmp = null;
     try {
         $this->app->removePluginConfigCache();
         Cache::clear($this->app, false);
         $tmp = $this->createTempDir();
         $this->unpackPluginArchive($path, $tmp);
         //一旦テンポラリに展開
         $this->checkPluginArchiveContent($tmp);
         $config = $this->readYml($tmp . '/' . self::CONFIG_YML);
         $event = $this->readYml($tmp . '/event.yml');
         if ($plugin->getCode() != $config['code']) {
             throw new PluginException('new/old plugin code is different.');
         }
         if ($plugin->getName() != $config['name']) {
             throw new PluginException('new/old plugin name is different.');
         }
         $pluginBaseDir = $this->calcPluginDir($config['code']);
         $this->deleteFile($tmp);
         // テンポラリのファイルを削除
         $this->unpackPluginArchive($path, $pluginBaseDir);
         // 問題なければ本当のplugindirへ
         $this->updatePlugin($plugin, $config, $event);
         // dbにプラグイン登録
         $this->app->writePluginConfigCache();
     } catch (PluginException $e) {
         foreach (array($tmp) as $dir) {
             if (file_exists($dir)) {
                 $fs = new Filesystem();
                 $fs->remove($dir);
             }
         }
         throw $e;
     }
     return true;
 }
Exemple #10
0
 public function delete(Application $app, $id)
 {
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $Block = $app['eccube.repository.block']->findOrCreate($id, $DeviceType);
     // ユーザーが作ったブロックのみ削除する
     if ($Block->getDeletableFlg() > 0) {
         $tplDir = $app['eccube.repository.block']->getWriteTemplatePath($DeviceType);
         $file = $tplDir . '/' . $Block->getFileName() . '.twig';
         $fs = new Filesystem();
         if ($fs->exists($file)) {
             $fs->remove($file);
         }
         $app['orm.em']->remove($Block);
         $app['orm.em']->flush();
     }
     \Eccube\Util\Cache::clear($app, false);
     return $app->redirect($app->url('admin_content_block'));
 }
Exemple #11
0
 /**
  * マイグレーションを実行し, 完了画面を表示させる
  *
  * @param InstallApplication $app
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function migration_end(InstallApplication $app, Request $request)
 {
     $this->doMigrate();
     $config_app = new \Eccube\Application();
     // install用のappだとconfigが取れないので
     $config_app->initialize();
     $config_app->boot();
     \Eccube\Util\Cache::clear($config_app, true);
     return $app['twig']->render('migration_end.twig', array('publicPath' => '..' . RELATIVE_PUBLIC_DIR_PATH . '/'));
 }
 /**
  * ブロックを削除.
  *
  * @param \Eccube\Application $app
  *
  * @throws \Exception
  */
 private function removeDataBlock($app)
 {
     // Blockの取得(file_nameはアプリケーションの仕組み上必ずユニーク)
     /** @var \Eccube\Entity\Block $Block */
     $Block = $app['eccube.repository.block']->findOneBy(array('file_name' => $this->blockFileName));
     if (!$Block) {
         Cache::clear($app, false);
         return;
     }
     $em = $app['orm.em'];
     try {
         // BlockPositionの削除
         $blockPositions = $Block->getBlockPositions();
         /** @var \Eccube\Entity\BlockPosition $BlockPosition */
         foreach ($blockPositions as $BlockPosition) {
             $Block->removeBlockPosition($BlockPosition);
             $em->remove($BlockPosition);
         }
         // Blockの削除
         $em->remove($Block);
         $em->flush();
     } catch (\Exception $e) {
         throw $e;
     }
     Cache::clear($app, false);
 }