/** * {@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()); }
public function testRemoveMapping() { $this->assetManager->expects($this->once())->method('findAssetMappings')->with(Expr::startsWith('abcd', AssetMapping::UUID))->willReturn(array($mapping = new AssetMapping('/app/public', 'local', '/'))); $this->assetManager->expects($this->once())->method('removeRootAssetMapping')->with($mapping->getUuid()); $args = self::$removeCommand->parseArgs(new StringArgs('abcd')); $this->assertSame(0, $this->handler->handleRemove($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; }