protected function removeCache()
 {
     $cachePath = $this->getServiceKernel()->getParameter('kernel.root_dir') . '/cache/' . $this->getServiceKernel()->getEnvironment();
     $filesystem = new Filesystem();
     $filesystem->remove($cachePath);
     if (empty($errors)) {
         PluginUtil::refresh();
     }
 }
Example #2
0
 public function upgradesCountAction(Request $request)
 {
     $apps = $this->getAppService()->checkAppUpgrades();
     $cop = $this->getAppService()->checkAppCop();
     if ($cop && isset($cop['cop']) && $cop['cop'] == 1) {
         $this->getSettingService()->set('_app_cop', 1);
         PluginUtil::refresh();
     }
     return $this->createJsonResponse(count($apps));
 }
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->initServiceKernel();
     $name = $input->getArgument('bundlename');
     if (!$name) {
         throw new \RuntimeException("插件名称不能为空!");
     }
     if (!preg_match('/^[a-zA-Z\\s]+$/', $name)) {
         throw new \RuntimeException("插件名称只能为英文!");
     }
     $output->writeln("<comment>正在移除插件`{$name}`:</comment>");
     $pluginDir = dirname($this->getContainer()->getParameter('kernel.root_dir')) . '/plugins/' . $name;
     if (!is_dir($pluginDir)) {
         throw new \RuntimeException("插件目录{$pluginDir}不存在!");
     }
     $output->writeln("<comment>  - 移除插件目录...</comment><info>OK</info>");
     $this->deleteDir($pluginDir);
     $app = $this->getAppService()->uninstallApp($name);
     $output->writeln("<comment>  - 移除应用记录...</comment><info>OK</info>");
     PluginUtil::refresh();
     $output->writeln("<comment>  - 刷新插件缓存...</comment><info>OK</info>");
 }
Example #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->initServiceKernel();
     $code = $input->getArgument('code');
     $output->writeln("<comment>注册插件`{$code}`:</comment>");
     $pluginDir = dirname($this->getContainer()->getParameter('kernel.root_dir')) . '/plugins/' . $code;
     if (!is_dir($pluginDir)) {
         throw new \RuntimeException("插件目录{$pluginDir}不存在!");
     }
     $output->writeln("<comment>  - 检查插件目录...</comment><info>OK</info>");
     $meta = $this->parseMeta($code, $pluginDir);
     $output->writeln("<comment>  - 获取插件元信息...</comment><info>OK</info>");
     $this->executeInstall($pluginDir);
     $output->writeln("<comment>  - 执行安装脚本...</comment><info>OK</info>");
     $app = $this->getAppService()->registerApp($meta);
     $output->writeln("<comment>  - 添加应用记录...</comment><info>OK</info>");
     PluginUtil::refresh();
     $output->writeln("<comment>  - 刷新插件缓存...</comment><info>OK</info>");
     $this->initBlock($pluginDir . '/block.json', $this->getContainer());
     $output->writeln("<comment>  - 插入编辑区元信息成功...</comment><info>OK</info>");
     $output->writeln("<info>注册成功....</info>");
 }
Example #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->initServiceKernel();
     PluginUtil::refresh();
     $output->writeln("<info>刷新成功....</info>");
 }
Example #6
0
 public function beginPackageUpdate($packageId, $type, $index = 0)
 {
     $errors = array();
     $package = $packageDir = null;
     try {
         $package = $this->getCenterPackageInfo($packageId);
         if (empty($package)) {
             throw $this->createServiceException("应用包#{$packageId}不存在或网络超时,读取包信息失败");
         }
         $packageDir = $this->makePackageFileUnzipDir($package);
     } catch (\Exception $e) {
         $errors[] = $e->getMessage();
         goto last;
     }
     if (empty($index)) {
         try {
             $this->_deleteFilesForPackageUpdate($package, $packageDir);
         } catch (\Exception $e) {
             $errors[] = "删除文件时发生了错误:{$e->getMessage()}";
             $this->createPackageUpdateLog($package, 'ROLLBACK', implode('\\n', $errors));
             goto last;
         }
         try {
             $this->_replaceFileForPackageUpdate($package, $packageDir);
         } catch (\Exception $e) {
             $errors[] = "复制升级文件时发生了错误:{$e->getMessage()}";
             $this->createPackageUpdateLog($package, 'ROLLBACK', implode('\\n', $errors));
             goto last;
         }
     }
     try {
         $info = $this->_execScriptForPackageUpdate($package, $packageDir, $type, $index);
         if (isset($info['index'])) {
             goto last;
         }
     } catch (\Exception $e) {
         $errors[] = "执行升级/安装脚本时发生了错误:{$e->getMessage()}";
         $this->createPackageUpdateLog($package, 'ROLLBACK', implode('\\n', $errors));
         goto last;
     }
     try {
         $cachePath = $this->getKernel()->getParameter('kernel.root_dir') . '/cache/' . $this->getKernel()->getEnvironment();
         $filesystem = new Filesystem();
         $filesystem->remove($cachePath);
     } catch (\Exception $e) {
         $errors[] = "应用安装升级成功,但刷新缓存失败!请检查{$cachePath}的权限";
         $this->createPackageUpdateLog($package, 'ROLLBACK', implode('\\n', $errors));
         goto last;
     }
     if (empty($errors)) {
         $this->updateAppForPackageUpdate($package, $packageDir);
         $this->createPackageUpdateLog($package, 'SUCCESS');
         PluginUtil::refresh();
     }
     last:
     $this->_submitRunLogForPackageUpdate('执行升级', $package, $errors);
     return empty($info) ? $errors : $info;
 }
Example #7
0
 public function storageAction(Request $request)
 {
     $storageSetting = $this->getSettingService()->get('storage', array());
     $default = array('upload_mode' => 'local', 'cloud_access_key' => '', 'cloud_secret_key' => '', 'cloud_bucket' => '', 'cloud_api_server' => '', 'video_quality' => 'low', 'video_audio_quality' => 'low', 'video_watermark' => 0, 'video_watermark_image' => '', 'video_watermark_position' => 'topright', 'video_fingerprint' => 0);
     $storageSetting = array_merge($default, $storageSetting);
     if ($request->getMethod() == 'POST') {
         $storageSetting = $request->request->all();
         $this->getSettingService()->set('storage', $storageSetting);
         if (!empty($storageSetting['cloud_access_key']) or !empty($storageSetting['cloud_secret_key'])) {
             if (!empty($storageSetting['cloud_access_key']) and !empty($storageSetting['cloud_secret_key'])) {
                 $factory = new CloudClientFactory();
                 $client = $factory->createClient($storageSetting);
                 $keyCheckResult = $client->checkKey();
             } else {
                 $keyCheckResult = array('error' => 'error');
             }
         } else {
             $keyCheckResult = array('status' => 'ok');
         }
         $cop = $this->getAppService()->checkAppCop();
         if ($cop && isset($cop['cop']) && $cop['cop'] == 1) {
             $this->getSettingService()->set('_app_cop', 1);
         } else {
             $this->getSettingService()->set('_app_cop', 0);
         }
         PluginUtil::refresh();
         $this->getLogService()->info('system', 'update_settings', "更新云平台设置", $storageSetting);
         if (!empty($keyCheckResult['status']) && $keyCheckResult['status'] == 'ok') {
             $this->setFlashMessage('success', '云平台设置已保存!');
         } else {
             $this->setFlashMessage('danger', 'AccessKey或者SecretKey设置不正确,会影响到系统正常的运行,请修改设置。');
         }
     }
     return $this->render('TopxiaAdminBundle:System:storage.html.twig', array('storageSetting' => $storageSetting));
 }