Last active
August 23, 2019 20:26
-
-
Save kellymears/927af91b79a40a76772f69116c844a20 to your computer and use it in GitHub Desktop.
Utilize service providers
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 App\Composers\Concerns; | |
use Roots\Acorn\Application; | |
use Illuminate\Support\Collection; | |
trait Services | |
{ | |
/** | |
* Service Provider | |
* @var array | |
*/ | |
// public static $services = [ | |
// 'Parser' => 'commonmark', | |
// ]; | |
/** | |
* Utilize service providers | |
* | |
* @param array $services | |
* @return void | |
*/ | |
protected function resolveServices() : void | |
{ | |
if (isset(self::$services) && !empty(self::$services)) { | |
Collection::make(self::$services)->each(function ($alias, $call) { | |
$callable = Application::getInstance()->make($alias); | |
$this->$call = $callable; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment