-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the remains of kohana #1841
Changes from 17 commits
f666cae
5221ad1
381756b
1b58122
43b1ddf
7034f15
c11471e
124eb58
ef2e1ed
73c28f7
66acf80
ef94959
8c37b77
d356517
457f93e
926b7db
d4f76db
03d80aa
5b2137e
a7d8bb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,26 @@ class AppServiceProvider extends ServiceProvider | |
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->configure('cdn'); | ||
$this->app->configure('media'); | ||
$this->app->configure('ratelimiter'); | ||
$this->app->configure('multisite'); | ||
$this->app->configure('ohanzee-db'); | ||
|
||
$this->registerServicesFromAura(); | ||
|
||
$this->registerFilesystem(); | ||
$this->registerMailer(); | ||
$this->registerDataSources(); | ||
|
||
$this->configureAuraDI(); | ||
|
||
// Hack, must construct it to register route :/ | ||
$this->app->make('datasources'); | ||
} | ||
|
||
public function registerServicesFromAura() | ||
{ | ||
$this->app->singleton(\Ushahidi\Factory\UsecaseFactory::class, function ($app) { | ||
// Just return it from AuraDI | ||
|
@@ -22,20 +42,10 @@ public function register() | |
// Just return it from AuraDI | ||
return service('repository.message'); | ||
}); | ||
} | ||
|
||
$this->app->configure('cdn'); | ||
$this->app->configure('ratelimiter'); | ||
$this->app->configure('multisite'); | ||
|
||
// Add filesystem | ||
$this->app->singleton('filesystem', function ($app) { | ||
return $app->loadComponent( | ||
'filesystems', | ||
\Illuminate\Filesystem\FilesystemServiceProvider::class, | ||
'filesystem' | ||
); | ||
}); | ||
|
||
public function registerMailer() | ||
{ | ||
// Add mailer | ||
$this->app->singleton('mailer', function ($app) { | ||
return $app->loadComponent( | ||
|
@@ -44,103 +54,68 @@ public function register() | |
'mailer' | ||
); | ||
}); | ||
} | ||
|
||
public function registerFilesystem() | ||
{ | ||
// Add filesystem | ||
$this->app->singleton('filesystem', function ($app) { | ||
return $app->loadComponent( | ||
'filesystems', | ||
\Illuminate\Filesystem\FilesystemServiceProvider::class, | ||
'filesystem' | ||
); | ||
}); | ||
} | ||
|
||
public function registerDataSources() | ||
{ | ||
$this->app->singleton('datasources', function () { | ||
return $this->app->loadComponent( | ||
'datasources', | ||
\Ushahidi\App\DataSource\DataSourceServiceProvider::class, | ||
'datasources' | ||
); | ||
}); | ||
|
||
$this->configureAuraDI(); | ||
|
||
// Hack, must construct it to register route :/ | ||
$this->app->make('datasources'); | ||
} | ||
|
||
// @todo move most of this elsewhere | ||
protected function configureAuraDI() | ||
{ | ||
$di = service(); | ||
|
||
// Multisite db | ||
$di->set('site', function () use ($di) { | ||
$site = ''; | ||
|
||
// Is this a multisite install? | ||
$multisite = config('multisite.enabled'); | ||
if ($multisite) { | ||
$site = $di->get('multisite')->getSite(); | ||
} | ||
|
||
return $site; | ||
}); | ||
|
||
// Site config | ||
$di->set('site.config', function () use ($di) { | ||
return $di->get('repository.config')->get('site')->asArray(); | ||
}); | ||
|
||
// Client Url | ||
$di->set('clienturl', function () use ($di) { | ||
return $this->getClientUrl($di->get('site.config')); | ||
}); | ||
|
||
// Feature config | ||
$di->set('features', function () use ($di) { | ||
return $di->get('repository.config')->get('features')->asArray(); | ||
}); | ||
|
||
// Roles config settings | ||
$di->set('roles.enabled', function () use ($di) { | ||
$config = $di->get('features'); | ||
|
||
return $config['roles']['enabled']; | ||
}); | ||
|
||
// Feature config | ||
$di->set('features.limits', function () use ($di) { | ||
$config = $di->get('features'); | ||
|
||
return $config['limits']; | ||
}); | ||
|
||
// Webhooks config settings | ||
$di->set('webhooks.enabled', function () use ($di) { | ||
$config = $di->get('features'); | ||
|
||
return $config['webhooks']['enabled']; | ||
}); | ||
|
||
// Post Locking config settings | ||
$di->set('post-locking.enabled', function () use ($di) { | ||
$config = $di->get('features'); | ||
|
||
return $config['post-locking']['enabled']; | ||
}); | ||
$this->configureAuraServices($di); | ||
$this->injectAuraConfig($di); | ||
} | ||
|
||
// Redis config settings | ||
$di->set('redis.enabled', function () use ($di) { | ||
$config = $di->get('features'); | ||
protected function configureAuraServices(\Aura\Di\ContainerInterface $di) | ||
{ | ||
// Configure mailer | ||
$di->set('tool.mailer', $di->lazyNew('Ushahidi\App\Tools\LumenMailer', [ | ||
'mailer' => app('mailer'), | ||
'siteConfig' => $di->lazyGet('site.config'), | ||
'clientUrl' => $di->lazyGet('clienturl') | ||
])); | ||
|
||
return $config['redis']['enabled']; | ||
}); | ||
// Setup user session service | ||
$di->set('session', $di->lazyNew(\Ushahidi\App\Tools\LumenSession::class, [ | ||
'userRepo' => $di->lazyGet('repository.user') | ||
])); | ||
|
||
// Data import config settings | ||
$di->set('data-import.enabled', function () use ($di) { | ||
$config = $di->get('features'); | ||
// Multisite db | ||
$di->set('kohana.db.multisite', function () use ($di) { | ||
$config = config('ohanzee-db'); | ||
|
||
return $config['data-import']['enabled']; | ||
return \Ohanzee\Database::instance('multisite', $config['default']); | ||
}); | ||
|
||
$di->set('features.data-providers', function () use ($di) { | ||
$config = $di->get('features'); | ||
|
||
return array_filter($config['data-providers']); | ||
// Deployment db | ||
$di->set('kohana.db', function () use ($di) { | ||
return \Ohanzee\Database::instance('deployment', $this->getDbConfig($di)); | ||
}); | ||
} | ||
|
||
protected function injectAuraConfig(\Aura\Di\ContainerInterface $di) | ||
{ | ||
// CDN Config settings | ||
$di->set('cdn.config', function () use ($di) { | ||
return config('cdn'); | ||
|
@@ -151,15 +126,21 @@ protected function configureAuraDI() | |
return config('ratelimiter'); | ||
}); | ||
|
||
// Private deployment config settings | ||
// @todo move to repo | ||
$di->set('site.private', function () use ($di) { | ||
$site = $di->get('site.config'); | ||
$features = $di->get('features'); | ||
return $site['private'] | ||
and $features['private']['enabled']; | ||
// Multisite db | ||
// Move multisite enabled check to class and move to src/App | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when we talk about multisite install, is that the way we have the setup for ushahidi.io clients? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's correct, yes |
||
$di->set('site', function () use ($di) { | ||
$site = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a todo to make this a logical default? |
||
|
||
// Is this a multisite install? | ||
$multisite = config('multisite.enabled'); | ||
if ($multisite) { | ||
$site = $di->get('multisite')->getSite(); | ||
} | ||
|
||
return $site; | ||
}); | ||
|
||
// Move multisite enabled check to class and move to src/App | ||
$di->set('tool.uploader.prefix', function () use ($di) { | ||
// Is this a multisite install? | ||
$multisite = config('multisite.enabled'); | ||
|
@@ -170,17 +151,26 @@ protected function configureAuraDI() | |
return ''; | ||
}); | ||
|
||
// Configure mailer | ||
$di->set('tool.mailer', $di->lazyNew('Ushahidi\App\Tools\LumenMailer', [ | ||
'mailer' => app('mailer'), | ||
'siteConfig' => $di->lazyGet('site.config'), | ||
'clientUrl' => $di->lazyGet('clienturl') | ||
])); | ||
// Client Url | ||
$di->set('clienturl', function () use ($di) { | ||
return $this->getClientUrl($di->get('site.config')); | ||
}); | ||
} | ||
|
||
// @todo move to auth provider? | ||
$di->set('session', $di->lazyNew(\Ushahidi\App\Tools\LumenSession::class, [ | ||
'userRepo' => $di->lazyGet('repository.user') | ||
])); | ||
protected function getDbConfig(\Aura\Di\ContainerInterface $di) | ||
{ | ||
// Kohana injection | ||
// DB config | ||
$config = config('ohanzee-db'); | ||
$config = $config['default']; | ||
|
||
// Is this a multisite install? | ||
$multisite = config('multisite.enabled'); | ||
if ($multisite) { | ||
$config = $di->get('multisite')->getDbConfig(); | ||
} | ||
|
||
return $config; | ||
} | ||
|
||
protected function getClientUrl($config) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it matter that it is using AuraDI to register usecase and repository.message?