Skip to content

Commit d6fb95a

Browse files
author
Mads Møller
authored
Merge pull request #1 from Napp/add_features_to_modulecore
Add ability to register features
2 parents 40ddea2 + 7e813af commit d6fb95a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,20 @@ class FormsServiceProvider extends CoreServiceProvider
2424

2525
public const EXTENSION_FORM_BUILDER = 'extension.form_builder';
2626

27+
public const FEATURE_ALLOW_SOMETHING = 'feature.form_allow_something';
28+
2729
protected $repositories = [
2830
FormsRepositoryInterface::class => FormsRepository::class
2931
];
3032

33+
protected $features = [
34+
self::FEATURE_ALLOW_SOMETHING => [
35+
'translation_key',
36+
true // boolean true if the feature has settings
37+
],
38+
self::FEATURE_ALLOW_SOMETHING => 'translation_key'
39+
];
40+
3141
protected $events = [
3242
FormWasSubmittedEvent::class => SendFormSubmissionEmailListener::class
3343
];

src/Provider/CoreServiceProvider.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class CoreServiceProvider extends ServiceProvider
5757
*/
5858
protected $commands = [];
5959

60+
/**
61+
* @var array
62+
*/
63+
protected $features = [];
64+
6065
/**
6166
* @return void
6267
*/
@@ -91,6 +96,9 @@ public function boot()
9196
// Extensions
9297
$this->registerExtensions($this->extensions);
9398

99+
// Features
100+
$this->registerFeatures($this->features);
101+
94102
// Permissions
95103
$this->registerPermissions($this->permissions);
96104
}
@@ -163,6 +171,21 @@ protected function registerExtensions(array $extensions): void
163171
}
164172
}
165173

174+
/**
175+
* @param array $features
176+
*/
177+
protected function registerFeatures(array $features): void
178+
{
179+
foreach ($features as $key => $translation) {
180+
if (\is_array($translation)) {
181+
ExtensionRegistrar::addFeature($key, $translation[0], $translation[1]);
182+
continue;
183+
}
184+
185+
ExtensionRegistrar::addFeature($key, $translation);
186+
}
187+
}
188+
166189
/**
167190
* @param array $permissions
168191
*/

0 commit comments

Comments
 (0)