|
@@ 278-302 (lines=25) @@
|
| 275 |
|
* @param Plugin $Plugin |
| 276 |
|
* @return RedirectResponse |
| 277 |
|
*/ |
| 278 |
|
public function enable(Application $app, Plugin $Plugin) |
| 279 |
|
{ |
| 280 |
|
$this->isTokenValid($app); |
| 281 |
|
|
| 282 |
|
if ($Plugin->isEnabled()) { |
| 283 |
|
$app->addError('admin.plugin.already.enable', 'admin'); |
| 284 |
|
} else { |
| 285 |
|
$requires = $this->pluginService->findRequirePluginNeedEnable($Plugin->getCode()); |
| 286 |
|
if (!empty($requires)) { |
| 287 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $requires[0]]); |
| 288 |
|
$dependName = $requires[0]; |
| 289 |
|
if ($DependPlugin) { |
| 290 |
|
$dependName = $DependPlugin->getName(); |
| 291 |
|
} |
| 292 |
|
$message = $app->trans('admin.plugin.enable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 293 |
|
$app->addError($message, 'admin'); |
| 294 |
|
|
| 295 |
|
return $app->redirect($app->url('admin_store_plugin')); |
| 296 |
|
} |
| 297 |
|
$this->pluginService->enable($Plugin); |
| 298 |
|
$app->addSuccess('admin.plugin.enable.complete', 'admin'); |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
return $app->redirect($app->url('admin_store_plugin')); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
/** |
| 305 |
|
* 対象のプラグインを無効にします。 |
|
@@ 313-338 (lines=26) @@
|
| 310 |
|
* @param Plugin $Plugin |
| 311 |
|
* @return RedirectResponse |
| 312 |
|
*/ |
| 313 |
|
public function disable(Application $app, Plugin $Plugin) |
| 314 |
|
{ |
| 315 |
|
$this->isTokenValid($app); |
| 316 |
|
|
| 317 |
|
if ($Plugin->isEnabled()) { |
| 318 |
|
$dependents = $this->pluginService->findDependentPluginNeedDisable($Plugin->getCode()); |
| 319 |
|
if (!empty($dependents)) { |
| 320 |
|
$dependName = $dependents[0]; |
| 321 |
|
$DependPlugin = $this->pluginRepository->findOneBy(['code' => $dependents[0]]); |
| 322 |
|
if ($DependPlugin) { |
| 323 |
|
$dependName = $DependPlugin->getName(); |
| 324 |
|
} |
| 325 |
|
$message = $app->trans('admin.plugin.disable.depend', ['%name%' => $Plugin->getName(), '%depend_name%' => $dependName]); |
| 326 |
|
$app->addError($message, 'admin'); |
| 327 |
|
|
| 328 |
|
return $app->redirect($app->url('admin_store_plugin')); |
| 329 |
|
} |
| 330 |
|
|
| 331 |
|
$this->pluginService->disable($Plugin); |
| 332 |
|
$app->addSuccess('admin.plugin.disable.complete', 'admin'); |
| 333 |
|
} else { |
| 334 |
|
$app->addError('admin.plugin.already.disable', 'admin'); |
| 335 |
|
} |
| 336 |
|
|
| 337 |
|
return $app->redirect($app->url('admin_store_plugin')); |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
/** |
| 341 |
|
* 対象のプラグインを削除します。 |