/** * {@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); }
function testCreateWithUuid() { $uuid = Uuid::uuid4(); $mapping = new AssetMapping('/blog/public', 'local', '/blog', $uuid); $this->assertSame('/blog/public', $mapping->getGlob()); $this->assertSame('local', $mapping->getTargetName()); $this->assertSame('/blog', $mapping->getWebPath()); $this->assertSame($uuid, $mapping->getUuid()); }
/** * {@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 testUpdateMappingForce() { $args = self::$updateCommand->parseArgs(new StringArgs('abcd --path /new --force')); $mapping = new AssetMapping('/app/public', 'local', '/'); $uuid = $mapping->getUuid(); $this->assetManager->expects($this->once())->method('findAssetMappings')->with(Expr::startsWith('abcd', AssetMapping::UUID))->willReturn(array($mapping)); $this->assetManager->expects($this->once())->method('addRootAssetMapping')->willReturnCallback(function (AssetMapping $mapping, $flags) use($uuid) { PHPUnit_Framework_Assert::assertSame('/new', $mapping->getGlob()); PHPUnit_Framework_Assert::assertSame('/', $mapping->getWebPath()); PHPUnit_Framework_Assert::assertSame('local', $mapping->getTargetName()); PHPUnit_Framework_Assert::assertSame($uuid, $mapping->getUuid()); PHPUnit_Framework_Assert::assertSame(AssetManager::OVERRIDE | AssetManager::IGNORE_TARGET_NOT_FOUND, $flags); }); $this->assertSame(0, $this->handler->handleUpdate($args)); }
private function mappingsEqual(AssetMapping $mapping1, AssetMapping $mapping2) { if ($mapping1->getUuid() !== $mapping2->getUuid()) { return false; } if ($mapping1->getGlob() !== $mapping2->getGlob()) { return false; } if ($mapping1->getWebPath() !== $mapping2->getWebPath()) { return false; } if ($mapping1->getTargetName() !== $mapping2->getTargetName()) { return false; } return true; }