/** * {@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); }
/** * {@inheritdoc} */ public function addRootAssetMapping(AssetMapping $mapping, $flags = 0) { if (!($flags & self::IGNORE_SERVER_NOT_FOUND) && !$this->servers->contains($mapping->getServerName())) { throw NoSuchServerException::forServerName($mapping->getServerName()); } if (!($flags & self::OVERRIDE) && $this->hasAssetMapping($mapping->getUuid())) { throw DuplicateAssetMappingException::forUuid($mapping->getUuid()); } $this->discoveryManager->addRootBinding(new BindingDescriptor($mapping->getGlob() . '{,/**/*}', DiscoveryUrlGenerator::BINDING_TYPE, array(DiscoveryUrlGenerator::SERVER_PARAMETER => $mapping->getServerName(), DiscoveryUrlGenerator::PATH_PARAMETER => $mapping->getServerPath()), 'glob', $mapping->getUuid()), $flags & self::OVERRIDE ? DiscoveryManager::OVERRIDE : 0); }
/** * Handles the "bind --update <uuid>" command. * * @param Args $args The console arguments. * * @return int The status code. */ public function handleUpdate(Args $args) { $flags = $args->isOptionSet('force') ? DiscoveryManager::OVERRIDE | DiscoveryManager::IGNORE_TYPE_NOT_FOUND | DiscoveryManager::IGNORE_TYPE_NOT_ENABLED : DiscoveryManager::OVERRIDE; $bindingToUpdate = $this->getBindingByUuidPrefix($args->getArgument('uuid')); if (!$bindingToUpdate->getContainingPackage() instanceof RootPackage) { throw new RuntimeException(sprintf('Can only update bindings in the package "%s".', $this->packages->getRootPackageName())); } $query = $bindingToUpdate->getQuery(); $typeName = $bindingToUpdate->getTypeName(); $language = $bindingToUpdate->getLanguage(); $bindingParams = $bindingToUpdate->getParameterValues(); if ($args->isOptionSet('query')) { $query = $args->getOption('query'); } if ($args->isOptionSet('type')) { $typeName = $args->getOption('type'); } if ($args->isOptionSet('language')) { $language = $args->getOption('language'); } $this->parseParams($args, $bindingParams); $this->unsetParams($args, $bindingParams); $updatedBinding = new BindingDescriptor(Path::makeAbsolute($query, $this->currentPath), $typeName, $bindingParams, $language, $bindingToUpdate->getUuid()); if ($this->bindingsEqual($bindingToUpdate, $updatedBinding)) { throw new RuntimeException('Nothing to update.'); } $this->discoveryManager->addRootBinding($updatedBinding, $flags); return 0; }