Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #39 from jenkoian/default-label
Browse files Browse the repository at this point in the history
Add default label for register_flag too.
  • Loading branch information
jamesrwilliams authored Apr 22, 2021
2 parents 1a32610 + 1d47f78 commit 95b8a16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions includes/api/api.general.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @package flagpole
*/

use Flagpole\Flag;
use Flagpole\Flagpole;

/**
Expand All @@ -23,6 +24,7 @@ function flagpole_register_flag( $args ) {
'enforced' => false,
'description' => '',
'stable' => false,
'label' => Flag::DEFAULT_LABEL

];

Expand Down
8 changes: 6 additions & 2 deletions includes/class-flag.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* @package FeatureFlag
*/
class Flag {
/**
* Default label for flags without a label to be grouped under.
*/
const DEFAULT_LABEL = 'All';

/**
* Flags can be enforced. When they are they bypass
Expand Down Expand Up @@ -89,11 +93,11 @@ class Flag {
*/
public function __construct( $_key, $_name, $_enforced, $_description, $_stable, $_label ) {
$this->enforced = $_enforced;
$this->name = ( $_name ? $_name : '' );
$this->name = $_name ?: '';
$this->key = $_key;
$this->description = $_description;
$this->stable = $_stable;
$this->label = ( $_label ? $_label : 'All' );
$this->label = $_label ?: self::DEFAULT_LABEL;
}

/**
Expand Down

0 comments on commit 95b8a16

Please sign in to comment.