|
@@ 248-277 (lines=30) @@
|
| 245 |
|
* |
| 246 |
|
* @return RedirectResponse |
| 247 |
|
*/ |
| 248 |
|
public function enable(Plugin $Plugin, CacheUtil $cacheUtil) |
| 249 |
|
{ |
| 250 |
|
$this->isTokenValid(); |
| 251 |
|
|
| 252 |
|
if ($Plugin->isEnabled()) { |
| 253 |
|
$this->addError('admin.plugin.already.enable', 'admin'); |
| 254 |
|
} else { |
| 255 |
|
$requires = $this->pluginService->findRequirePluginNeedEnable($Plugin->getCode()); |
| 256 |
|
if (!empty($requires)) { |
| 257 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $requires[0]]); |
| 258 |
|
$dependName = $requires[0]; |
| 259 |
|
if ($DependPlugin) { |
| 260 |
|
$dependName = $DependPlugin->getName(); |
| 261 |
|
} |
| 262 |
|
$message = trans('admin.plugin.enable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 263 |
|
$this->addError($message, 'admin'); |
| 264 |
|
|
| 265 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 266 |
|
} |
| 267 |
|
$this->pluginService->enable($Plugin); |
| 268 |
|
$this->addSuccess('admin.plugin.enable.complete', 'admin'); |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
// キャッシュを削除してリダイレクト |
| 272 |
|
// リダイレクトにredirectToRoute関数を使用していないのは、削除したキャッシュが再生成されてしまうため。 |
| 273 |
|
$url = $this->generateUrl('admin_store_plugin'); |
| 274 |
|
$cacheUtil->clearCache(); |
| 275 |
|
|
| 276 |
|
return $this->redirect($url); |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
/** |
| 280 |
|
* 対象のプラグインを無効にします。 |
|
@@ 289-321 (lines=33) @@
|
| 286 |
|
* |
| 287 |
|
* @return RedirectResponse |
| 288 |
|
*/ |
| 289 |
|
public function disable(Plugin $Plugin, CacheUtil $cacheUtil) |
| 290 |
|
{ |
| 291 |
|
$this->isTokenValid(); |
| 292 |
|
|
| 293 |
|
if ($Plugin->isEnabled()) { |
| 294 |
|
$dependents = $this->pluginService->findDependentPluginNeedDisable($Plugin->getCode()); |
| 295 |
|
if (!empty($dependents)) { |
| 296 |
|
$dependName = $dependents[0]; |
| 297 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $dependents[0]]); |
| 298 |
|
if ($DependPlugin) { |
| 299 |
|
$dependName = $DependPlugin->getName(); |
| 300 |
|
} |
| 301 |
|
$message = trans('admin.plugin.disable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 302 |
|
$this->addError($message, 'admin'); |
| 303 |
|
|
| 304 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
$this->pluginService->disable($Plugin); |
| 308 |
|
$this->addSuccess('admin.plugin.disable.complete', 'admin'); |
| 309 |
|
} else { |
| 310 |
|
$this->addError('admin.plugin.already.disable', 'admin'); |
| 311 |
|
|
| 312 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
// キャッシュを削除してリダイレクト |
| 316 |
|
// リダイレクトにredirectToRoute関数を使用していないのは、削除したキャッシュが再生成されてしまうため。 |
| 317 |
|
$url = $this->generateUrl('admin_store_plugin'); |
| 318 |
|
$cacheUtil->clearCache(); |
| 319 |
|
|
| 320 |
|
return $this->redirect($url); |
| 321 |
|
} |
| 322 |
|
|
| 323 |
|
/** |
| 324 |
|
* 対象のプラグインを削除します。 |
|
@@ 333-362 (lines=30) @@
|
| 330 |
|
* |
| 331 |
|
* @return RedirectResponse |
| 332 |
|
*/ |
| 333 |
|
public function uninstall(Plugin $Plugin) |
| 334 |
|
{ |
| 335 |
|
$this->isTokenValid(); |
| 336 |
|
|
| 337 |
|
if ($Plugin->isEnabled()) { |
| 338 |
|
$this->addError('admin.plugin.uninstall.error.not_disable', 'admin'); |
| 339 |
|
|
| 340 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
// Check other plugin depend on it |
| 344 |
|
$pluginCode = $Plugin->getCode(); |
| 345 |
|
$otherDepend = $this->pluginService->findDependentPlugin($pluginCode); |
| 346 |
|
if (!empty($otherDepend)) { |
| 347 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $otherDepend[0]]); |
| 348 |
|
$dependName = $otherDepend[0]; |
| 349 |
|
if ($DependPlugin) { |
| 350 |
|
$dependName = $DependPlugin->getName(); |
| 351 |
|
} |
| 352 |
|
$message = trans('admin.plugin.uninstall.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 353 |
|
$this->addError($message, 'admin'); |
| 354 |
|
|
| 355 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 356 |
|
} |
| 357 |
|
|
| 358 |
|
$this->pluginService->uninstall($Plugin); |
| 359 |
|
$this->addSuccess('admin.plugin.uninstall.complete', 'admin'); |
| 360 |
|
|
| 361 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
/** |
| 365 |
|
* @Route("/%eccube_admin_route%/store/plugin/handler", name="admin_store_plugin_handler") |