rutkai/featureflipperbundle

此包已被废弃,不再维护。未建议替代包。

为基于Symfony2的项目提供高级功能切换支持

v1.0.1 2015-03-17 10:22 UTC

This package is not auto-updated.

Last update: 2023-03-18 09:04:57 UTC


README

Build Status

此包为Symfony2提供功能切换界面。主要功能:

  • 在twigs和控制器中检查功能(通过DI)
  • 为功能指定过期日期
  • 为功能指定负责人

安装

将此包添加到composer.json文件

"require": {
    ...
    "rutkai/featureflipperbundle": "~1.0"
},

在AppKernel中注册它

$bundles = array(
    ...
    new Rutkai\FeatureFlipperBundle\RutkaiFeatureFlipperBundle(),
);

使用方法

配置

# config.yml

rutkai_feature_flipper:
    enable_undefined_feature: true  # Optional, sets the default strategy for undefined features
    expiration_warning: 7           # Optional, expiration e-mails will be sent to responsibles if expiration occurs within the next x days
    feature_class: Rutkai\FeatureFlipperBundle\Feature\Feature  # Optional, default feature container, must implement FeatureInterface
    templates:
        warning_console: RutkaiFeatureFlipperBundle:FeatureCheck:warning.txt.twig # Optional, output warning template for feature check command
        warning_email: RutkaiFeatureFlipperBundle:FeatureCheck:warning.txt.twig   # Optional, e-mail warning template for feature check command
        alert_console: RutkaiFeatureFlipperBundle:FeatureCheck:alert.txt.twig     # Optional, output alert template for feature check command
        alert_email: RutkaiFeatureFlipperBundle:FeatureCheck:alert.txt.twig       # Optional, e-mail alert template for feature check command
    email:
        from: architect@example.com # Required, sender of the warning (default: noreply@example.com)
        subject: Expired feature    # Optional, subject for the warnings
    features:
        feature_id:
            enabled: true                       # Required
            expiration: "2015-03-03 12:00:00"   # Optional
            responsible: "András Rutkai"        # Optional
            responsible_email: email@domain.com # Optional
        feature_id_2:
            enabled: false
            expiration: ~   # no expiration
            responsible: ~  # no responsible

Twig

{% if feature_enabled("feature_id") %}
    ...
{% endif %}

Twig函数

  • feature_enabled('feature_id')
  • has_feature('feature_id')

控制器或服务

$featureManager = $this->get('feature.manager');
if ($featureManager->isEnabled("feature_id"))
    ...

功能管理函数

  • $featureManager->isEnabled('feature_id')
  • $featureManager->hasFeature('feature_id')
  • $featureManager->getFeature('feature_id')
  • $featureManager->addFeature($feature) 其中 $feature 实现了 FeatureInterface

路线图

  • 1.0.0: 基于YML/XML的配置,使用电子邮件的通知
  • 1.1.0: Doctrine后端用于存储功能
  • 1.2.0: Redis后端用于存储功能