Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Janis
/
btflags
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
48468437
authored
2018-09-18 14:28:19 +0800
by
Joshua Tundag
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update README.md
1 parent
3a9aa681
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
4 deletions
README.md
README.md
View file @
4846843
...
...
@@ -3,18 +3,25 @@ Flag Manager for Baytech Sites.
## Define Flag Directory in your constants.php file
```
define('
DEFAULT_PPG', '14
');
```
php
define('
FLAGS_DIR', '
<Desired
directory
to
store
flags
.
json
file
>
');
```
## Initialize Flag Manager
```
php
$flagManager = new \BTFlags\FlagManager();
```
## Register Flags
```
php
$flagManager = new \BTFlags\FlagManager();
$flagManager->register();
```
### Data Structure
```
```
php
$requestData = array(
'name' => null|string,
'is_encrypyed' => true|false,
...
...
@@ -29,8 +36,28 @@ $requestData = array(
);
```
## CRUD
#### Tip:
```
php
// application/config/hooks.php
$hook['post_controller_constructor'][] = array(
'class' => 'Flag',
'function' => 'register',
'filename' => 'Flag.php',
'filepath' => 'hooks',
);
// application/hooks/Flags.php
class Flag{
public function register(){
$flagManager = new \LawFormsUSA\Flags\FlagManager();
$flagManager->register();
}
}
```
## CRUD
```
php
// Create a Flag
$created = $flagManager->create($requestData);
...
...
@@ -43,3 +70,46 @@ $updated = $flagManager->update($requestData);
// Get all Flags
$flags = $flagManager->all();
```
## Retrieving a flag
```
php
// Parameters:
// $flagName: String = Name of the flag.
// (Optional) $encrypted: bool = If the inputted $flagName is encrypted, set this to true, otherwise, false.
// (Optional) $default: String = Default value if flag is empty.
// (Option) $driver: String = Driver (cookie or session).
\BTFlags\Flags::get($flagName, [$encrypted, $default, $driver]);
```
#### Example Usage:
```
php
// Getting an encrypted flag
// Example Flag:
// Name:
// 'mode' => 'edom'
// Accepted Values:
// 'live' => 'prod'
// 'test' => 'dev'
\BTFlags\Flags::get('edom', true);
// Getting a non-encrypted flag
\BTFlags\Flags::get('source');
```
#### Tip:
```
php
// utility_helper.php
if (!function_exists('flag')){
function flag($flag, $default = null, $encrypted = false){
return \BTFlags\Flags::get($flag, $encrypted, $default);
}
}
// Use anywhere:
flag('mode');
flag('source');
flag('pmt', 'rec');
```
\ No newline at end of file
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment