Merge pull request #1257 from vtalbot/develop

Add bundle:uninstall, bundle:unpublish, migrate:rollback and migrate:reset for bundles
This commit is contained in:
Taylor Otwell
2013-01-05 13:20:10 -08:00
4 changed files with 94 additions and 2 deletions

View File

@@ -61,6 +61,43 @@ class Bundler extends Task {
}
}
/**
* Uninstall the given bundles from the application.
*
* @param array $bundles
* @return void
*/
public function uninstall($bundles)
{
if (count($bundles) == 0)
{
throw new \Exception("Tell me what bundle to uninstall.");
}
foreach ($bundles as $name)
{
if ( ! Bundle::exists($name))
{
echo "Bundle [{$name}] is not installed.";
continue;
}
echo "Uninstalling [{$name}]...".PHP_EOL;
$migrator = IoC::resolve('task: migrate');
$migrator->reset($name);
$publisher = IoC::resolve('bundle.publisher');
$publisher->unpublish($name);
$location = Bundle::path($name);
File::rmdir($location);
echo "Bundle [{$name}] has been uninstalled!".PHP_EOL;
}
echo "Now, you have to remove those bundle from your application/bundles.php".PHP_EOL;
}
/**
* Upgrade the given bundles for the application.
*
@@ -159,6 +196,19 @@ class Bundler extends Task {
array_walk($bundles, array(IoC::resolve('bundle.publisher'), 'publish'));
}
/**
* Delete bundle assets from the public directory.
*
* @param array $bundles
* @return void
*/
public function unpublish($bundles)
{
if (count($bundles) == 0) $bundles = Bundle::names();
array_walk($bundles, array(IoC::resolve('bundle.publisher'), 'unpublish'));
}
/**
* Install a bundle using a provider.
*

View File

@@ -28,6 +28,26 @@ class Publisher {
echo "Assets published for bundle [$bundle].".PHP_EOL;
}
/**
* Delete a bundle's assets from the public directory
*
* @param string $bundle
* @return void
*/
public function unpublish($bundle)
{
if ( ! Bundle::exists($bundle))
{
echo "Bundle [$bundle] is not registered.";
return;
}
File::rmdir(path('public').'bundles'.DS.$bundle);
echo "Assets deleted for bundle [$bundle].".PHP_EOL;
}
/**
* Copy the contents of a bundle's assets to the public folder.
*