/** * Creates the installation request. * * @param ResourceInstaller $installer The used resource installer. * @param InstallerDescriptor $installerDescriptor The descriptor of the * resource installer. * @param ResourceCollection $resources The resources to install. * @param AssetMapping $mapping The web path mapping. * @param InstallTarget $installTarget The install target. * @param string $rootDir The project's root directory. */ public function __construct(ResourceInstaller $installer, InstallerDescriptor $installerDescriptor, ResourceCollection $resources, AssetMapping $mapping, InstallTarget $installTarget, $rootDir) { $glob = $mapping->getGlob(); $parameterValues = $installTarget->getParameterValues(); $this->validateParameterValues($parameterValues, $installerDescriptor); $this->installer = $installer; $this->installerDescriptor = $installerDescriptor; $this->resources = $resources; $this->mapping = $mapping; $this->installTarget = $installTarget; $this->rootDir = $rootDir; $this->basePath = Glob::isDynamic($glob) ? Glob::getBasePath($glob) : $glob; $this->parameterValues = array_replace($installerDescriptor->getParameterValues(), $parameterValues); }
public function testCreateWithDefaultUrlFormat() { $target = new InstallTarget('local', 'symlink', 'web/assets'); $this->assertSame('/%s', $target->getUrlFormat()); $this->assertSame(array(), $target->getParameterValues()); }
private function targetToData(InstallTarget $target) { $data = new stdClass(); $data->installer = $target->getInstallerName(); $data->location = $target->getLocation(); if (InstallTarget::DEFAULT_URL_FORMAT !== ($urlFormat = $target->getUrlFormat())) { $data->{'url-format'} = $urlFormat; } if ($parameters = $target->getParameterValues()) { $data->parameters = (object) $parameters; } return $data; }
private function targetsEqual(InstallTarget $target1, InstallTarget $target2) { if ($target1->getName() !== $target2->getName()) { return false; } if ($target1->getInstallerName() !== $target2->getInstallerName()) { return false; } if ($target1->getLocation() !== $target2->getLocation()) { return false; } if ($target1->getUrlFormat() !== $target2->getUrlFormat()) { return false; } $parameters1 = $target1->getParameterValues(); $parameters2 = $target2->getParameterValues(); ksort($parameters1); ksort($parameters2); if ($parameters1 !== $parameters2) { return false; } return true; }