| @@ 645-689 (lines=45) @@ | ||
| 642 | /** |
|
| 643 | * {@inheritdoc} |
|
| 644 | */ |
|
| 645 | public function enableBindingDescriptor(Uuid $uuid) |
|
| 646 | { |
|
| 647 | $this->assertPackagesLoaded(); |
|
| 648 | ||
| 649 | if (!$this->bindingDescriptors->contains($uuid)) { |
|
| 650 | throw NoSuchBindingException::forUuid($uuid); |
|
| 651 | } |
|
| 652 | ||
| 653 | $bindingDescriptor = $this->bindingDescriptors->get($uuid); |
|
| 654 | $package = $bindingDescriptor->getContainingPackage(); |
|
| 655 | ||
| 656 | if ($package instanceof RootPackage) { |
|
| 657 | throw NonRootPackageExpectedException::cannotEnableBinding($uuid, $package->getName()); |
|
| 658 | } |
|
| 659 | ||
| 660 | if ($bindingDescriptor->isTypeNotFound()) { |
|
| 661 | throw NoSuchTypeException::forTypeName($bindingDescriptor->getTypeName()); |
|
| 662 | } |
|
| 663 | ||
| 664 | if ($bindingDescriptor->isTypeNotEnabled()) { |
|
| 665 | throw TypeNotEnabledException::forTypeName($bindingDescriptor->getTypeName()); |
|
| 666 | } |
|
| 667 | ||
| 668 | if ($bindingDescriptor->isEnabled()) { |
|
| 669 | return; |
|
| 670 | } |
|
| 671 | ||
| 672 | $tx = new Transaction(); |
|
| 673 | ||
| 674 | try { |
|
| 675 | $syncOp = $this->syncBindingUuid($uuid); |
|
| 676 | $syncOp->takeSnapshot(); |
|
| 677 | ||
| 678 | $tx->execute($this->enableBindingUuid($uuid, $package->getInstallInfo())); |
|
| 679 | $tx->execute($syncOp); |
|
| 680 | ||
| 681 | $this->saveRootPackageFile(); |
|
| 682 | ||
| 683 | $tx->commit(); |
|
| 684 | } catch (Exception $e) { |
|
| 685 | $tx->rollback(); |
|
| 686 | ||
| 687 | throw $e; |
|
| 688 | } |
|
| 689 | } |
|
| 690 | ||
| 691 | /** |
|
| 692 | * {@inheritdoc} |
|
| @@ 694-738 (lines=45) @@ | ||
| 691 | /** |
|
| 692 | * {@inheritdoc} |
|
| 693 | */ |
|
| 694 | public function disableBindingDescriptor(Uuid $uuid) |
|
| 695 | { |
|
| 696 | $this->assertPackagesLoaded(); |
|
| 697 | ||
| 698 | if (!$this->bindingDescriptors->contains($uuid)) { |
|
| 699 | throw NoSuchBindingException::forUuid($uuid); |
|
| 700 | } |
|
| 701 | ||
| 702 | $bindingDescriptor = $this->bindingDescriptors->get($uuid); |
|
| 703 | $package = $bindingDescriptor->getContainingPackage(); |
|
| 704 | ||
| 705 | if ($package instanceof RootPackage) { |
|
| 706 | throw NonRootPackageExpectedException::cannotDisableBinding($uuid, $package->getName()); |
|
| 707 | } |
|
| 708 | ||
| 709 | if ($bindingDescriptor->isTypeNotFound()) { |
|
| 710 | throw NoSuchTypeException::forTypeName($bindingDescriptor->getTypeName()); |
|
| 711 | } |
|
| 712 | ||
| 713 | if ($bindingDescriptor->isTypeNotEnabled()) { |
|
| 714 | throw TypeNotEnabledException::forTypeName($bindingDescriptor->getTypeName()); |
|
| 715 | } |
|
| 716 | ||
| 717 | if ($bindingDescriptor->isDisabled()) { |
|
| 718 | return; |
|
| 719 | } |
|
| 720 | ||
| 721 | $tx = new Transaction(); |
|
| 722 | ||
| 723 | try { |
|
| 724 | $syncOp = $this->syncBindingUuid($uuid); |
|
| 725 | $syncOp->takeSnapshot(); |
|
| 726 | ||
| 727 | $tx->execute($this->disableBindingUuid($uuid, $package->getInstallInfo())); |
|
| 728 | $tx->execute($syncOp); |
|
| 729 | ||
| 730 | $this->saveRootPackageFile(); |
|
| 731 | ||
| 732 | $tx->commit(); |
|
| 733 | } catch (Exception $e) { |
|
| 734 | $tx->rollback(); |
|
| 735 | ||
| 736 | throw $e; |
|
| 737 | } |
|
| 738 | } |
|
| 739 | ||
| 740 | /** |
|
| 741 | * {@inheritdoc} |
|