/**
  * {@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);
 }
 private function generateUrlForBinding(ResourceBinding $binding, $repositoryPath)
 {
     $bindingPath = Glob::getStaticPrefix($binding->getQuery());
     $webBasePath = trim($binding->getParameterValue(AssetPlugin::PATH_PARAMETER), '/');
     $webPath = substr_replace($repositoryPath, $webBasePath, 0, strlen($bindingPath));
     $targetName = $binding->getParameterValue(AssetPlugin::TARGET_PARAMETER);
     if (!$this->targets->contains($targetName)) {
         throw new CannotGenerateUrlException(sprintf('The target "%s" mapped for path "%s" does not exist.', $targetName, $repositoryPath));
     }
     $target = $this->targets->get($targetName);
     return sprintf($target->getUrlFormat(), ltrim($webPath, '/'));
 }
 /**
  * {@inheritdoc}
  */
 public function prepareInstallation(AssetMapping $mapping)
 {
     $glob = $mapping->getGlob();
     $targetName = $mapping->getTargetName();
     $resources = $this->repo->find($glob);
     if ($resources->isEmpty()) {
         throw NotInstallableException::noResourceMatches($glob);
     }
     if (!$this->installTargets->contains($targetName)) {
         throw NotInstallableException::targetNotFound($targetName);
     }
     $target = $this->installTargets->get($targetName);
     $installerName = $target->getInstallerName();
     if (!$this->installerManager->hasInstallerDescriptor($installerName)) {
         throw NotInstallableException::installerNotFound($installerName);
     }
     $installerDescriptor = $this->installerManager->getInstallerDescriptor($installerName);
     $installer = $this->loadInstaller($installerDescriptor);
     $rootDir = $this->environment->getRootDirectory();
     $params = new InstallationParams($installer, $installerDescriptor, $resources, $mapping, $target, $rootDir);
     $installer->validateParams($params);
     return $params;
 }
 public function testContainsWithDefaultTarget()
 {
     $this->assertFalse($this->collection->contains(InstallTarget::DEFAULT_TARGET));
     $this->collection->add($this->target1);
     $this->assertTrue($this->collection->contains(InstallTarget::DEFAULT_TARGET));
 }
 /**
  * {@inheritdoc}
  */
 public function hasTarget($targetName)
 {
     $this->assertTargetsLoaded();
     return $this->targets->contains($targetName);
 }