private function updateDuplicateMarksForTypeName($typeName) { if (!$this->typeDescriptors->contains($typeName)) { return; } $typeDescriptors = $this->typeDescriptors->listByTypeName($typeName); $duplicate = count($typeDescriptors) > 1; foreach ($typeDescriptors as $typeDescriptor) { $typeDescriptor->markDuplicate($duplicate); } }
/** * {@inheritdoc} */ public function rollback() { // sanity check if ($this->typeDescriptor->isLoaded() || !$this->containingModule) { return; } // never fails with the check before $this->typeDescriptor->load($this->containingModule); if ($this->wasRemoved) { // never fails $this->typeDescriptors->add($this->typeDescriptor); } }
/** * {@inheritdoc} */ public function execute() { // sanity check if ($this->bindingDescriptor->isLoaded()) { return; } $typeName = $this->bindingDescriptor->getTypeName(); $typeDescriptor = $this->typeDescriptors->contains($typeName) ? $this->typeDescriptors->getFirst($typeName) : null; $this->bindingDescriptor->load($this->containingPackage, $typeDescriptor); $uuid = $this->bindingDescriptor->getUuid(); if ($this->bindingDescriptors->contains($uuid)) { $this->previousDescriptor = $this->bindingDescriptors->get($uuid); } $this->bindingDescriptors->add($this->bindingDescriptor); }
/** * 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; }
/** * {@inheritdoc} */ public function rollback() { // sanity check if (!$this->typeDescriptor->isLoaded()) { return; } $typeName = $this->typeDescriptor->getTypeName(); // never fails with the check before $this->typeDescriptor->unload(); if ($this->previousDescriptor && $this->previousDescriptor->isLoaded()) { // never fails $this->typeDescriptors->add($this->previousDescriptor); } else { // never fails $this->typeDescriptors->remove($typeName, $this->containingPackage->getName()); } }
/** * {@inheritdoc} */ public function execute() { if (!$this->snapshotTaken) { throw new LogicException('takeSnapshot() was not called'); } // Remember for rollback() $this->enabledTypeAfter = null; if ($this->typeDescriptors->contains($this->typeName)) { foreach ($this->typeDescriptors->listByTypeName($this->typeName) as $typeDescriptor) { if ($typeDescriptor->isEnabled()) { $this->enabledTypeAfter = $typeDescriptor; } } } $this->syncTypeName($this->enabledTypeBefore, $this->enabledTypeAfter); }
private function emitWarningForDuplicateTypes() { foreach ($this->typeDescriptors->getTypeNames() as $typeName) { $packageNames = $this->typeDescriptors->getPackageNames($typeName); if (count($packageNames) > 1) { $lastPackageName = array_pop($packageNames); $this->logger->warning(sprintf('The packages "%s" and "%s" contain type definitions for ' . 'the same type "%s". The type has been disabled.', implode('", "', $packageNames), $lastPackageName, $typeName)); } } }