-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Forge facade for Laravel integration
- Loading branch information
1 parent
61a1441
commit 86e69ee
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Laravel\Forge\Facades; | ||
|
||
use Laravel\Forge\ForgeManager; | ||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @mixin \Laravel\Forge\Forge | ||
*/ | ||
class Forge extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
public static function getFacadeAccessor() | ||
{ | ||
return ForgeManager::class; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Laravel\Forge; | ||
|
||
use Illuminate\Support\Traits\ForwardsCalls; | ||
|
||
/** | ||
* @mixin \Laravel\Forge\Forge | ||
*/ | ||
class ForgeManager | ||
{ | ||
use ForwardsCalls; | ||
|
||
/** | ||
* The Forge instance. | ||
* | ||
* @var \Laravel\Forge\Forge | ||
*/ | ||
protected $forge; | ||
|
||
/** | ||
* Create a new Forge manager instance. | ||
* | ||
* @param string $token | ||
*/ | ||
public function __construct($token) | ||
{ | ||
$this->forge = new Forge($token); | ||
} | ||
|
||
/** | ||
* Dynamically pass methods to the Forge instance. | ||
* | ||
* @param string $method | ||
* @param array $parameters | ||
* @return mixed | ||
*/ | ||
public function __call(string $method, array $parameters): mixed | ||
{ | ||
return $this->forwardCallTo($this->forge, $method, $parameters); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Laravel\Forge; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Contracts\Foundation\Application; | ||
|
||
class ForgeServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton(ForgeManager::class, function ($app) { | ||
return new ForgeManager($app['config']->get('services.forge.token')); | ||
}); | ||
} | ||
} |