/** * {@inheritdoc} */ public function rollback() { // sanity check if (!$this->bindingDescriptor->isLoaded()) { return; } // never fails with the check before $this->bindingDescriptor->unload(); if ($this->previousDescriptor) { // never fails $this->bindingDescriptors->add($this->previousDescriptor); } else { // never fails $this->bindingDescriptors->remove($this->bindingDescriptor->getUuid()); } }
/** * {@inheritdoc} */ public function execute() { // sanity check if (!$this->bindingDescriptor->isLoaded()) { return; } $this->containingPackage = $this->bindingDescriptor->getContainingPackage(); $this->typeDescriptor = $this->bindingDescriptor->getTypeDescriptor(); $uuid = $this->bindingDescriptor->getUuid(); // never fails with the check in the beginning $this->bindingDescriptor->unload(); if ($this->bindingDescriptors->contains($uuid) && $this->bindingDescriptor === $this->bindingDescriptors->get($uuid)) { // never fails $this->bindingDescriptors->remove($uuid); $this->wasRemoved = true; } }
/** * Unloads and loads a binding descriptor. * * The descriptor is remembered and reloaded again in {@link postRollback()} * if the intercepted operation needs to be rolled back. * * @param BindingDescriptor $bindingDescriptor The descriptor to reload. */ protected function reloadBindingDescriptor(BindingDescriptor $bindingDescriptor) { if (!$bindingDescriptor->isLoaded()) { return; } // Keep backup of containing package before calling unload() $containingPackage = $bindingDescriptor->getContainingPackage(); $typeName = $bindingDescriptor->getTypeName(); $typeDescriptor = $this->typeDescriptors->getEnabled($typeName); // never fails with the check in the beginning $bindingDescriptor->unload(); // never fails after unloading, given that the type name matches // (which we can guarantee here) $bindingDescriptor->load($containingPackage, $typeDescriptor); $this->reloadedDescriptors[] = $bindingDescriptor; }