/**
  * Returns the target with the given name.
  *
  * @param string $targetName The target name.
  *
  * @return InstallTarget The target.
  *
  * @throws NoSuchTargetException If the target does not exist.
  */
 public function get($targetName)
 {
     if (InstallTarget::DEFAULT_TARGET === $targetName) {
         return $this->getDefaultTarget();
     }
     if (!isset($this->targets[$targetName])) {
         throw NoSuchTargetException::forTargetName($targetName);
     }
     return $this->targets[$targetName];
 }
 /**
  * {@inheritdoc}
  */
 public function addRootAssetMapping(AssetMapping $mapping, $flags = 0)
 {
     if (!($flags & self::IGNORE_TARGET_NOT_FOUND) && !$this->installTargets->contains($mapping->getTargetName())) {
         throw NoSuchTargetException::forTargetName($mapping->getTargetName());
     }
     if (!($flags & self::OVERRIDE) && $this->hasAssetMapping($mapping->getUuid())) {
         throw DuplicateAssetMappingException::forUuid($mapping->getUuid());
     }
     $this->discoveryManager->addRootBinding(new BindingDescriptor($mapping->getGlob() . '{,/**/*}', AssetPlugin::BINDING_TYPE, array(AssetPlugin::TARGET_PARAMETER => $mapping->getTargetName(), AssetPlugin::PATH_PARAMETER => $mapping->getWebPath()), 'glob', $mapping->getUuid()), $flags & self::OVERRIDE ? DiscoveryManager::OVERRIDE : 0);
 }
Esempio n. 3
0
 public function handleRemove(Args $args)
 {
     $targetName = $args->getArgument('name');
     if (!$this->targetManager->hasTarget($targetName)) {
         throw NoSuchTargetException::forTargetName($targetName);
     }
     $this->targetManager->removeTarget($targetName);
     return 0;
 }