2021-06-01 19:54:59 +02:00

70 lines
1.7 KiB
PHP

<?php namespace GermanAirlinesVa\Graphql;
use System\Classes\PluginBase;
use App;
use Config;
use Illuminate\Foundation\AliasLoader;
use GermanAirlinesVa\Graphql\Classes\GraphqlServiceProvider;
class Plugin extends PluginBase
{
public function registerComponents()
{
}
public function registerSettings()
{
}
public function boot()
{
App::make('October\Rain\Support\ClassLoader')->addDirectories('graphql');
$this->bootPackages();
App::register(GraphqlServiceProvider::class);
}
public function bootPackages()
{
// Get the namespace of the current plugin to use in accessing the Config of the plugin
$pluginNamespace = str_replace('\\', '.', strtolower(__NAMESPACE__));
// Instantiate the AliasLoader for any aliases that will be loaded
$aliasLoader = AliasLoader::getInstance();
// Get the packages to boot
$packages = Config::get($pluginNamespace . '::packages');
// Boot each package
foreach ($packages as $name => $options)
{
// Setup the configuration for the package, pulling from this plugin's config
if (!empty($options['config']) && !empty($options['config_namespace']))
{
Config::set($options['config_namespace'], $options['config']);
}
// Register any Service Providers for the package
if (!empty($options['providers']))
{
foreach ($options['providers'] as $provider)
{
App::register($provider);
}
}
// Register any Aliases for the package
if (!empty($options['aliases']))
{
foreach ($options['aliases'] as $alias => $path)
{
$aliasLoader->alias($alias, $path);
}
}
}
return $packages;
}
}