@@ 424-455 (lines=32) @@ | ||
421 | /** |
|
422 | * {@inheritdoc} |
|
423 | */ |
|
424 | public function enable(Entities\IPackage $package) |
|
425 | { |
|
426 | if ($this->getStatus($package) === Entities\IPackage::STATE_ENABLED) { |
|
427 | throw new Exceptions\InvalidArgumentException(sprintf('Package \'%s\' is already enabled', $package->getName())); |
|
428 | } |
|
429 | ||
430 | $dependencyResolver = $this->getDependencySolver(); |
|
431 | $dependencyResolver->testEnable($package); |
|
432 | ||
433 | foreach ($package->getScripts() as $class) { |
|
434 | try { |
|
435 | $installer = $this->getScript($class); |
|
436 | $installer->enable($package); |
|
437 | ||
438 | } catch (\Exception $e) { |
|
439 | foreach ($package->getScripts() as $class2) { |
|
440 | if ($class === $class2) { |
|
441 | break; |
|
442 | } |
|
443 | ||
444 | $installer = $this->getScript($class2); |
|
445 | $installer->disable($package); |
|
446 | } |
|
447 | ||
448 | throw new Exceptions\InvalidStateException($e->getMessage()); |
|
449 | } |
|
450 | } |
|
451 | ||
452 | $this->setStatus($package, Entities\IPackage::STATE_ENABLED); |
|
453 | ||
454 | $this->onEnable($this, $package); |
|
455 | } |
|
456 | ||
457 | /** |
|
458 | * {@inheritdoc} |
|
@@ 460-491 (lines=32) @@ | ||
457 | /** |
|
458 | * {@inheritdoc} |
|
459 | */ |
|
460 | public function disable(Entities\IPackage $package) |
|
461 | { |
|
462 | if ($this->getStatus($package) === Entities\IPackage::STATE_DISABLED) { |
|
463 | throw new Exceptions\InvalidArgumentException(sprintf('Package \'%s\' is already disabled', $package->getName())); |
|
464 | } |
|
465 | ||
466 | $dependencyResolver = $this->getDependencySolver(); |
|
467 | $dependencyResolver->testDisable($package); |
|
468 | ||
469 | foreach ($package->getScripts() as $class) { |
|
470 | try { |
|
471 | $installer = $this->getScript($class); |
|
472 | $installer->disable($package); |
|
473 | ||
474 | } catch (\Exception $e) { |
|
475 | foreach ($package->getScripts() as $class2) { |
|
476 | if ($class === $class2) { |
|
477 | break; |
|
478 | } |
|
479 | ||
480 | $installer = $this->getScript($class2); |
|
481 | $installer->enable($package); |
|
482 | } |
|
483 | ||
484 | throw new Exceptions\InvalidStateException($e->getMessage()); |
|
485 | } |
|
486 | } |
|
487 | ||
488 | $this->setStatus($package, Entities\IPackage::STATE_DISABLED); |
|
489 | ||
490 | $this->onDisable($this, $package); |
|
491 | } |
|
492 | ||
493 | /** |
|
494 | * {@inheritdoc} |