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, '/')); }
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 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; }
/** * {@inheritdoc} */ public function getTarget($targetName) { $this->assertTargetsLoaded(); return $this->targets->get($targetName); }