コード例 #1
0
 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));
 }
コード例 #2
0
 /**
  * {@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;
     }
 }