public function testRemoveWithDefaultTarget() { $this->collection->add($this->target1); $this->collection->add($this->target2); $this->collection->remove(InstallTarget::DEFAULT_TARGET); $this->assertSame($this->target2, $this->collection->get(InstallTarget::DEFAULT_TARGET)); }
/** * {@inheritdoc} */ public function removeTargets(Expression $expr) { $this->assertTargetsLoaded(); $previousTargets = $this->targets->toArray(); $previousData = $this->targetsData; $save = false; foreach ($this->targets as $target) { if ($target->match($expr)) { $this->targets->remove($target->getName()); unset($this->targetsData[$target->getName()]); $save = true; } } if (!$save) { return; } try { $this->persistTargetsData(); } catch (Exception $e) { $this->targets->replace($previousTargets); $this->targetsData = $previousData; throw $e; } }