Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3769879
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/app/Config/Features.php b/app/Config/Features.php
index ae2435d..0bb9fb0 100644
--- a/app/Config/Features.php
+++ b/app/Config/Features.php
@@ -1,92 +1,94 @@
<?php
namespace Nasqueron\Notifications\Config;
use Config;
/**
* The features class offers a sugar syntax to check if a feature is enabled
* in the Config repository, at app.features.
*
* Features could be added to config/app.php to the features array.
*/
class Features {
///
/// Feature information
///
/**
+ * Gets the configuration key for the specified feature name.
+ *
* @param string $feature The feature to get the config key
* @return string The config key
*/
private static function getFeatureConfigKey (string $feature) : string {
return 'app.features.' . $feature;
}
/**
* Determines if the specified feature is enabled.
*
* @param string $feature The feature to check in the config
* @return bool
*/
public static function isEnabled (string $feature) : bool {
$key = self::getFeatureConfigKey($feature);
return Config::has($key) && (bool)Config::get($key);
}
/**
* Enables a feature in our current configuration instance.
*
* @param string $feature The feature
*/
public static function enable (string $feature) : void {
$key = self::getFeatureConfigKey($feature);
Config::set($key, true);
}
/**
* Disables a feature in our current configuration instance.
*
* @param string $feature The feature
*/
public static function disable (string $feature) : void {
$key = self::getFeatureConfigKey($feature);
Config::set($key, false);
}
///
/// Features lists
///
/**
* Gets all the features, with the toggle status.
*
* @return array An array with features as keys, bool as values (true if enabled)
*/
public static function getAll () : array {
return Config::get('app.features');
}
/**
* Lists all the features.
*
* @return string[] a list of all features
*/
public static function getAvailable () : array {
$features = self::getAll();
return array_keys($features);
}
/**
- * Lists the enabled features
+ * Lists the enabled features.
*
* @return string[] a list of enabled features
*/
public static function getEnabled () : array {
$features = self::getAll();
$enabledFeatures = array_filter($features);
return array_keys($enabledFeatures);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 17:37 (8 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260657
Default Alt Text
(2 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment