Author: XE Developers (developers@xpressengine.com)
Exemplo n.º 1
0
 public function show($pluginId, PluginHandler $handler, PluginProvider $provider)
 {
     // refresh plugin cache
     $handler->getAllPlugins(true);
     $componentTypes = $this->getComponentTypes();
     $plugin = $handler->getPlugin($pluginId);
     $provider->sync($plugin);
     return XePresenter::make('show', compact('plugin', 'componentTypes'));
 }
Exemplo n.º 2
0
 /**
  * 현재 진행중인 플러그인 설치 작업 내역을 반환한다.
  *
  * @param ComposerFileWriter $writer composer file writer
  *
  * @return array|null
  */
 public function getOperation(ComposerFileWriter $writer)
 {
     $status = $writer->get('xpressengine-plugin.operation.status');
     if ($status === null) {
         return null;
     }
     $runnings = [];
     $runningMode = 'install';
     $runnings = $writer->get("xpressengine-plugin.operation.install", []);
     if (empty($runnings)) {
         $runningMode = 'update';
         $runnings = $writer->get("xpressengine-plugin.operation.update", []);
     }
     if (empty($runnings)) {
         $runningMode = 'uninstall';
         $runnings = $writer->get("xpressengine-plugin.operation.uninstall", []);
     }
     // operation이 없을 경우, return void
     if (empty($runnings)) {
         return null;
     }
     // operation이 있다.
     // expired 조사
     $deadline = $writer->get('xpressengine-plugin.operation.expiration_time');
     $expired = false;
     if ($deadline !== null && $deadline !== 0) {
         $deadline = Carbon::parse($deadline);
         if ($deadline->isPast()) {
             $expired = true;
         }
     }
     $runningsInfo = [];
     if (!empty($runnings)) {
         if ($runningMode === 'uninstall') {
             $package = current($runnings);
         } else {
             $package = key($runnings);
         }
         list(, $id) = explode('/', $package);
         $runningsInfo[$package] = $this->provider->find($id);
         $runningsInfo[$package]->pluginId = $id;
     }
     $changed = $writer->get('xpressengine-plugin.operation.changed', []);
     foreach ($changed as $type) {
         foreach ($type as $package => $version) {
             list(, $id) = explode('/', $package);
             if (!isset($runningsInfo[$package])) {
                 $runningsInfo[$package] = $this->provider->find($id);
             }
         }
     }
     if ($status === ComposerFileWriter::STATUS_RUNNING && $expired === true) {
         $status = 'expired';
     }
     return compact('runnings', 'status', 'runningMode', 'expired', 'changed', 'runningsInfo');
 }
 public function putDownloadPlugin($pluginId, PluginHandler $handler, PluginProvider $provider, ComposerFileWriter $writer, InterceptionHandler $interceptionHandler, SessionManager $session)
 {
     $handler->getAllPlugins(true);
     $plugin = $handler->getPlugin($pluginId);
     if ($plugin === null) {
         throw new HttpException(422, 'Plugin not found.');
     }
     // 자료실에서 플러그인 정보 조회
     $pluginData = $provider->find($pluginId);
     if ($pluginData === null) {
         throw new HttpException(422, "Can not find the plugin(" . $pluginId . ") that should be installed from the Market-place.");
     }
     $title = $pluginData->title;
     $name = $pluginData->name;
     $version = $pluginData->latest_release->version;
     $operation = $handler->getOperation($writer);
     if ($operation['status'] === ComposerFileWriter::STATUS_RUNNING) {
         throw new HttpException(422, "이미 진행중인 요청이 있습니다.");
     }
     $timeLimit = config('xe.plugin.operation.time_limit');
     $writer->reset()->cleanOperation();
     $writer->update($name, $version, Carbon::now()->addSeconds($timeLimit)->toDateTimeString())->write();
     $this->reserveOperation($writer, $timeLimit, function ($code) use($plugin) {
         if ($code === 0 && $plugin->checkUpdated()) {
             $plugin->update();
         }
     });
     return redirect()->route('settings.plugins')->with('alert', ['type' => 'success', 'message' => '플러그인의 새로운 버전을 다운로드하는 중입니다.']);
 }