92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php namespace GermanAirlinesVa\Graphql;
|
|
|
|
use System\Classes\PluginBase;
|
|
|
|
use App;
|
|
use Config;
|
|
use Illuminate\Database\DatabaseManager;
|
|
use Illuminate\Support\Facades\Broadcast;
|
|
use Illuminate\Foundation\AliasLoader;
|
|
use GermanAirlinesVa\Graphql\Classes\GraphqlServiceProvider;
|
|
use Nuwave\Lighthouse\Subscriptions\SubscriptionServiceProvider;
|
|
|
|
class Plugin extends PluginBase
|
|
{
|
|
public function registerComponents()
|
|
{
|
|
}
|
|
|
|
public function registerSettings()
|
|
{
|
|
return [
|
|
'settings' => [
|
|
'label' => 'germanairlinesva.graphql::lang.settings.label',
|
|
'description' => 'germanairlinesva.graphql::lang.settings.description',
|
|
'category' => 'system::lang.system.categories.cms',
|
|
'icon' => 'icon-compress',
|
|
'class' => 'GermanAirlinesVa\Graphql\Models\Settings',
|
|
'order' => 1000,
|
|
'keywords' => 'graphql',
|
|
'permissions' => ['germanairlinesva.graphql.schemas'],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
App::make('October\Rain\Support\ClassLoader')->addDirectories('graphql');
|
|
|
|
$this->bootPackages();
|
|
|
|
App::register(GraphqlServiceProvider::class);
|
|
App::register(SubscriptionServiceProvider::class);
|
|
|
|
$this->app->singleton(DatabaseManager::class, function ($app) {
|
|
return $app->make('db');
|
|
});
|
|
Broadcast::routes([
|
|
'prefix' => '',
|
|
'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication',
|
|
]);
|
|
|
|
Config::set('database.connections.germanairlinesva_graphql', Config::get('germanairlinesva.graphql::connection'));
|
|
Config::push('system.unencrypt_cookies', 'graphql-session-id');
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|