|
@@ 341-370 (lines=30) @@
|
| 338 |
|
* |
| 339 |
|
* @return RedirectResponse |
| 340 |
|
*/ |
| 341 |
|
public function enable(Plugin $Plugin, CacheUtil $cacheUtil) |
| 342 |
|
{ |
| 343 |
|
$this->isTokenValid(); |
| 344 |
|
|
| 345 |
|
if ($Plugin->isEnabled()) { |
| 346 |
|
$this->addError('admin.plugin.already.enable', 'admin'); |
| 347 |
|
} else { |
| 348 |
|
$requires = $this->pluginService->findRequirePluginNeedEnable($Plugin->getCode()); |
| 349 |
|
if (!empty($requires)) { |
| 350 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $requires[0]]); |
| 351 |
|
$dependName = $requires[0]; |
| 352 |
|
if ($DependPlugin) { |
| 353 |
|
$dependName = $DependPlugin->getName(); |
| 354 |
|
} |
| 355 |
|
$message = trans('admin.plugin.enable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 356 |
|
$this->addError($message, 'admin'); |
| 357 |
|
|
| 358 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 359 |
|
} |
| 360 |
|
$this->pluginService->enable($Plugin); |
| 361 |
|
$this->addSuccess('admin.plugin.enable.complete', 'admin'); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
// キャッシュを削除してリダイレクト |
| 365 |
|
// リダイレクトにredirectToRoute関数を使用していないのは、削除したキャッシュが再生成されてしまうため。 |
| 366 |
|
$url = $this->generateUrl('admin_store_plugin'); |
| 367 |
|
$cacheUtil->clearCache(); |
| 368 |
|
|
| 369 |
|
return $this->redirect($url); |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
/** |
| 373 |
|
* 対象のプラグインを無効にします。 |
|
@@ 382-414 (lines=33) @@
|
| 379 |
|
* |
| 380 |
|
* @return RedirectResponse |
| 381 |
|
*/ |
| 382 |
|
public function disable(Plugin $Plugin, CacheUtil $cacheUtil) |
| 383 |
|
{ |
| 384 |
|
$this->isTokenValid(); |
| 385 |
|
|
| 386 |
|
if ($Plugin->isEnabled()) { |
| 387 |
|
$dependents = $this->pluginService->findDependentPluginNeedDisable($Plugin->getCode()); |
| 388 |
|
if (!empty($dependents)) { |
| 389 |
|
$dependName = $dependents[0]; |
| 390 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $dependents[0]]); |
| 391 |
|
if ($DependPlugin) { |
| 392 |
|
$dependName = $DependPlugin->getName(); |
| 393 |
|
} |
| 394 |
|
$message = trans('admin.plugin.disable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 395 |
|
$this->addError($message, 'admin'); |
| 396 |
|
|
| 397 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 398 |
|
} |
| 399 |
|
|
| 400 |
|
$this->pluginService->disable($Plugin); |
| 401 |
|
$this->addSuccess('admin.plugin.disable.complete', 'admin'); |
| 402 |
|
} else { |
| 403 |
|
$this->addError('admin.plugin.already.disable', 'admin'); |
| 404 |
|
|
| 405 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 406 |
|
} |
| 407 |
|
|
| 408 |
|
// キャッシュを削除してリダイレクト |
| 409 |
|
// リダイレクトにredirectToRoute関数を使用していないのは、削除したキャッシュが再生成されてしまうため。 |
| 410 |
|
$url = $this->generateUrl('admin_store_plugin'); |
| 411 |
|
$cacheUtil->clearCache(); |
| 412 |
|
|
| 413 |
|
return $this->redirect($url); |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
/** |
| 417 |
|
* 対象のプラグインを削除します。 |
|
@@ 426-455 (lines=30) @@
|
| 423 |
|
* |
| 424 |
|
* @return RedirectResponse |
| 425 |
|
*/ |
| 426 |
|
public function uninstall(Plugin $Plugin) |
| 427 |
|
{ |
| 428 |
|
$this->isTokenValid(); |
| 429 |
|
|
| 430 |
|
if ($Plugin->isEnabled()) { |
| 431 |
|
$this->addError('admin.plugin.uninstall.error.not_disable', 'admin'); |
| 432 |
|
|
| 433 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 434 |
|
} |
| 435 |
|
|
| 436 |
|
// Check other plugin depend on it |
| 437 |
|
$pluginCode = $Plugin->getCode(); |
| 438 |
|
$otherDepend = $this->pluginService->findDependentPlugin($pluginCode); |
| 439 |
|
if (!empty($otherDepend)) { |
| 440 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $otherDepend[0]]); |
| 441 |
|
$dependName = $otherDepend[0]; |
| 442 |
|
if ($DependPlugin) { |
| 443 |
|
$dependName = $DependPlugin->getName(); |
| 444 |
|
} |
| 445 |
|
$message = trans('admin.plugin.uninstall.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 446 |
|
$this->addError($message, 'admin'); |
| 447 |
|
|
| 448 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 449 |
|
} |
| 450 |
|
|
| 451 |
|
$this->pluginService->uninstall($Plugin); |
| 452 |
|
$this->addSuccess('admin.plugin.uninstall.complete', 'admin'); |
| 453 |
|
|
| 454 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
/** |
| 458 |
|
* @Route("/%eccube_admin_route%/store/plugin/handler", name="admin_store_plugin_handler") |