mablae/time-window-bundle

Symfony bundle for time based feature flags

Installs: 2 811

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

v0.1.5 2016-05-27 01:55 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:51:06 UTC


README

This bundle implements implements basically daytime based feature flags.

NOTICE This bundle is the result of quickly decoupling some logic we already had duplicated in serveral places of an legacy codebase. If you are looking for a full featured Feature Toggle Bundle for Symfony you are probably better using https://github.com/qandidate-labs/qandidate-toggle-bundle

Feel free to contribute or leave feedback in the issues. <3

##Installation

Step 1: Install DatetimepickerBundle

php composer.phar require mablae/datetimepicker-bundle

Step 2: Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Mablae\TimeWindowBundle\MablaeTimeWindowBundle(),
    );
}

Step 3: Configure your named time windows:

# app/config/config.yml
mablae_time_window_:
    enabled: ~
    time_windows:
      in_the_morning:
        - { startTime : '06:00' , endTime: '08:00' }

At the moment there is no proper overlapping checks or sorting. The timewindow must be defined in correct order. The first timewindow that returns active wins.

Step 4: Use the voter service to ask, if a time-window is active

<?php 
/* ... */ 

$timeWindowService = $this->get('mablae_time_window.service');

$itsInTheMorning = $timeWindowService->isTimeWindowActive('in_the_morning')