<?php
namespace WpDownloader;
use WpDownloader\Log;
use WpDownloader\Utility;
class Distribution
{
public $localPath;
public $tempPath;
protected $components;
public function setComponents($components)
{
$this->components = $components;
}
public function compileComponent($component)
{
if ($component->isPlugin()){
$localPath = $component->getDistributionPath();
} else {
$localPath = "{$this->tempPath}/{$component->getDestinationPath()}";
}
Log::write("Moving from {$component->getSourcePath()} to $localPath", Log::INFO);
Utility::copyPath($component->getSourcePath(), $localPath);
}
public function build()
{
Utility::deleteDirectory($this->tempPath);
foreach ($this->components as $component) {
$pluginFile = $this->compileComponent($component);
}
Utility::deleteDirectory($this->localPath);
Log::write("Committing new distribution to {$this->localPath} from {$this->tempPath}.", Log::INFO);
rename($this->tempPath, $this->localPath);
}
}