コード例 #1
0
 /**
  * {@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);
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 public function testCreateWithEmptyWebPath()
 {
     $mapping = new AssetMapping('/blog/public', 'local', '');
     $this->assertSame('/', $mapping->getWebPath());
 }
コード例 #6
0
 /**
  * Returns the install path of a resource in the target location.
  *
  * This is a path relative to the root of the target location.
  *
  * @param Resource $resource The resource.
  *
  * @return string The web path.
  */
 public function getWebPathForResource(Resource $resource)
 {
     $relPath = Path::makeRelative($resource->getRepositoryPath(), $this->basePath);
     return '/' . trim($this->mapping->getWebPath() . '/' . $relPath, '/');
 }