|
@@ 247-271 (lines=25) @@
|
| 244 |
|
* |
| 245 |
|
* @return RedirectResponse |
| 246 |
|
*/ |
| 247 |
|
public function enable(Plugin $Plugin) |
| 248 |
|
{ |
| 249 |
|
$this->isTokenValid(); |
| 250 |
|
|
| 251 |
|
if ($Plugin->isEnabled()) { |
| 252 |
|
$this->addError('admin.plugin.already.enable', 'admin'); |
| 253 |
|
} else { |
| 254 |
|
$requires = $this->pluginService->findRequirePluginNeedEnable($Plugin->getCode()); |
| 255 |
|
if (!empty($requires)) { |
| 256 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $requires[0]]); |
| 257 |
|
$dependName = $requires[0]; |
| 258 |
|
if ($DependPlugin) { |
| 259 |
|
$dependName = $DependPlugin->getName(); |
| 260 |
|
} |
| 261 |
|
$message = trans('admin.plugin.enable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 262 |
|
$this->addError($message, 'admin'); |
| 263 |
|
|
| 264 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 265 |
|
} |
| 266 |
|
$this->pluginService->enable($Plugin); |
| 267 |
|
$this->addSuccess('admin.plugin.enable.complete', 'admin'); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
// 有効化できた場合はキャッシュを再生成する |
| 271 |
|
return $this->redirectToRoute('admin_store_clear_cache'); |
| 272 |
|
} |
| 273 |
|
|
| 274 |
|
/** |
|
@@ 284-312 (lines=29) @@
|
| 281 |
|
* |
| 282 |
|
* @return RedirectResponse |
| 283 |
|
*/ |
| 284 |
|
public function disable(Plugin $Plugin) |
| 285 |
|
{ |
| 286 |
|
$this->isTokenValid(); |
| 287 |
|
|
| 288 |
|
if ($Plugin->isEnabled()) { |
| 289 |
|
$dependents = $this->pluginService->findDependentPluginNeedDisable($Plugin->getCode()); |
| 290 |
|
if (!empty($dependents)) { |
| 291 |
|
$dependName = $dependents[0]; |
| 292 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $dependents[0]]); |
| 293 |
|
if ($DependPlugin) { |
| 294 |
|
$dependName = $DependPlugin->getName(); |
| 295 |
|
} |
| 296 |
|
$message = trans('admin.plugin.disable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 297 |
|
$this->addError($message, 'admin'); |
| 298 |
|
|
| 299 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
$this->pluginService->disable($Plugin); |
| 303 |
|
$this->addSuccess('admin.plugin.disable.complete', 'admin'); |
| 304 |
|
} else { |
| 305 |
|
$this->addError('admin.plugin.already.disable', 'admin'); |
| 306 |
|
|
| 307 |
|
return $this->redirectToRoute('admin_store_plugin'); |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
// 無効化できた場合はキャッシュを再生成する |
| 311 |
|
return $this->redirectToRoute('admin_store_clear_cache'); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
/** |
| 315 |
|
* プラグイン有効状態切り替え後にキャッシュを削除するためのルーティング |