Created
April 21, 2014 09:07
-
-
Save hailwood/11137012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Vapor\Theme\Composer; | |
use Composer\Package\PackageInterface; | |
use Composer\Installer\LibraryInstaller; | |
use Composer\Repository\InstalledRepositoryInterface; | |
class ThemeInstaller extends LibraryInstaller { | |
protected $type = 'vapor-theme'; | |
protected $thumbnailFile = 'thumbnail.png'; | |
public function install(InstalledRepositoryInterface $repo, PackageInterface $package){ | |
parent::install($repo, $package); | |
//copy thumbnail | |
} | |
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target){ | |
parent::update($repo, $initial, $target); | |
$this->removeThumbnail($initial); | |
$this->installThumbnail($target); | |
} | |
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package){ | |
parent::uninstall($repo, $package); | |
$this->removeThumbnail($package); | |
} | |
protected function installThumbnail(PackageInterface $package){ | |
if(!file_exists($this->getInstallPath($package).$this->thumbnailFile)){ | |
$this->io->write(' <warning>Skipped installation of '.$this->thumbnailFile.' for package '.$package->getName().': file not found in package</warning>'); | |
return; | |
} | |
$this->removeThumbnail($package); | |
$source = $this->getInstallPath($package).$this->thumbnailFile; | |
$destination = $this->vendorDir.'/../public/packages/'.$package->getPrettyName().'/'; | |
$this->filesystem->ensureDirectoryExists($destination); | |
copy($source, $destination.$this->thumbnailFile); | |
} | |
protected function removeThumbnail(PackageInterface $package){ | |
$this->filesystem->remove($this->vendorDir.'/../public/packages/'.$package->getPrettyName().'/'.$this->thumbnailFile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment