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, '/')); }
/** * Inserts the given binding ID into the index structures. * * @param int $id The binding ID. * @param ResourceBinding $binding The associated binding. */ protected function updateIndicesForId($id, ResourceBinding $binding) { $typeName = $binding->getType()->getName(); $this->queryIndex[$binding->getQuery()][$id] = true; if (!isset($this->typeIndex[$typeName])) { $this->typeIndex[$typeName] = array(); } $this->typeIndex[$typeName][$id] = true; }