Commit 14ab7c4e authored by Taylor Otwell's avatar Taylor Otwell

tweaking github provider.

parent a6c083f3
<?php namespace Laravel\CLI\Tasks\Bundle\Providers;
class Github implements Provider {
class Github extends Provider {
/**
* Install the given bundle into the application.
......@@ -10,25 +10,43 @@ class Github implements Provider {
*/
public function install($bundle)
{
$repository = "git@github.com:{$bundle['location']}.git";
$method = (Request::server('cli.zip')) ? 'zipball' : 'submodule';
$path = array_get($bundle, 'path', $bundle['name']);
$this->$method($bundle);
}
// If the installation target directory doesn't exist, we will create
// it recursively so that we can properly add the Git submodule for
// the bundle when we install.
if ( ! is_dir($target = dirname(path('bundle').$path)))
/**
* Install a Github hosted bundle from Zip.
*
* @param string $bundle
* @return void
*/
protected function zipball($bundle)
{
mkdir($target, 0777, true);
$zip = "https://github.com/{$bundle['location']}/zipball/master";
parent::zipball($zip, true);
}
/**
* Install a Github hosted bundle using submodules.
*
* @param string $bundle
* @return void
*/
protected function submodule($bundle)
{
$repository = "git@github.com:{$bundle['location']}.git";
$this->directory($bundle);
// We need to just extract the basename of the bundle path when
// adding the submodule. Of course, we can't add a submodule to
// a location outside of the Git repository, so we don't need
// the full bundle path.
$root = basename(path('bundle')).'/';
passthru('git submodule add '.$repository.' '.$root.$path);
passthru('git submodule add '.$repository.' '.$root.$this->path($bundle));
passthru('git submodule update');
}
......
<?php namespace Laravel\CLI\Tasks\Bundle\Providers;
interface Provider {
abstract class Provider {
/**
* Install the given bundle into the application.
......@@ -8,6 +8,36 @@ interface Provider {
* @param string $bundle
* @return void
*/
public function install($bundle);
abstract public function install($bundle);
/**
* Create the path to the bundle's dirname.
*
* @param array $bundle
* @return void
*/
protected function directory($bundle)
{
// If the installation target directory doesn't exist, we will create
// it recursively so that we can properly install the bundle to the
// correct path in the application.
$target = dirname(path('bundle').$this->path($bundle));
if ( ! is_dir($target))
{
mkdir($target, 0777, true);
}
}
/**
* Return the path for a given bundle.
*
* @param array $bundle
* @return string
*/
protected function path($bundle)
{
return array_get($bundle, 'path', $bundle['name']);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment