コード例 #1
0
ファイル: CopyInstaller.php プロジェクト: kormik/manager
 /**
  * {@inheritdoc}
  */
 public function installResource(Resource $resource, InstallationParams $params)
 {
     $documentRoot = Path::makeAbsolute($params->getDocumentRoot(), $params->getRootDirectory());
     if (!file_exists($documentRoot)) {
         mkdir($documentRoot, 0777, true);
     }
     $serverPath = $params->getServerPathForResource($resource);
     $parameterValues = $params->getParameterValues();
     $relative = !isset($parameterValues['relative']) || $parameterValues['relative'];
     $filesystemRepo = new FilesystemRepository($documentRoot, $this->symlinks, $relative);
     if ('/' === $serverPath) {
         foreach ($resource->listChildren() as $child) {
             $name = $child->getName();
             // If the resource is not attached, the name is empty
             if (!$name && $child instanceof FilesystemResource) {
                 $name = Path::getFilename($child->getFilesystemPath());
             }
             if ($name) {
                 $filesystemRepo->remove($serverPath . '/' . $name);
             }
         }
     } else {
         $filesystemRepo->remove($serverPath);
     }
     $filesystemRepo->add($serverPath, $resource);
 }
コード例 #2
0
 public function testCreate()
 {
     $installer = new TestInstaller();
     $descriptor = new InstallerDescriptor('test', get_class($installer), null, array(new InstallerParameter('param1', InstallerParameter::OPTIONAL, 'default1'), new InstallerParameter('param2', InstallerParameter::OPTIONAL, 'default2')));
     $resources = new ArrayResourceCollection();
     $mapping = new AssetMapping('/path/to/{css,js}', 'localhost', '/demo');
     $server = new Server('localhost', 'symlink', 'public_html', '/%s', array('param2' => 'custom'));
     $params = new InstallationParams($installer, $descriptor, $resources, $mapping, $server, '/root');
     $this->assertSame($installer, $params->getInstaller());
     $this->assertSame($descriptor, $params->getInstallerDescriptor());
     $this->assertSame($resources, $params->getResources());
     $this->assertSame('/root', $params->getRootDirectory());
     $this->assertSame('/path/to', $params->getBasePath());
     $this->assertSame('public_html', $params->getDocumentRoot());
     $this->assertSame('/demo', $params->getServerPath());
     $this->assertSame(array('param1' => 'default1', 'param2' => 'custom'), $params->getParameterValues());
 }