定制 flagception/contentful-activator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flagception/contentful-activator

最新稳定版本:1.0.0

Composer 安装命令:

composer require flagception/contentful-activator

包简介

Activator for manage feature toggles by contentful

README 文档

README

Manage feature flags for Flagception with Contentful!

Latest Stable Version Coverage Status Build Status Total Downloads License

SensioLabsInsight

Download the library

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

$ composer require flagception/contentful-activator

Usage

Just create a new ContentfulActivator instance and commit it to your feature manager:

// YourClass.php

class YourClass
{
    public function run()
    {
        // We need two arguments:
        //  1. A contentful client
        //  2. The content type name in contentful
        $activator = new ContentfulActivator($this->client, 'FeatureToggle');
        
        $manager = new FeatureManager($activator);
        if ($manager->isActive('your_feature_name')) {
            // do something
        }
    }
}

The ContentfulActivator need three arguments:

  • An instance of a contentful client
  • The contentful model type id as string
  • The field mappings as array ('name' and 'state') - Optional (default values are set)

If your contentful model looks like this ...

{
  "name": "Feature Management",
  "description": "Features verwalten",
  "displayField": "featureName",
  "fields": [
    {
      "id": "featureName",
      "name": "Feature",
      "type": "Text",
      "localized": false,
      "required": true,
      "validations": [],
      "disabled": false,
      "omitted": false
    },
    {
      "id": "isActive",
      "name": "Aktiv",
      "type": "Boolean",
      "localized": false,
      "required": true,
      "validations": [],
      "disabled": false,
      "omitted": false
    }
  ],
  "sys": {
    "space": {
      "sys": {
        "type": "Link",
        "linkType": "Space",
        "id": "9d8smn39"
      }
    },
    "id": "myFeatureModel",
    "type": "ContentType",
    "createdAt": "2017-12-07T15:54:07.255Z",
    "updatedAt": "2018-01-11T16:08:47.283Z",
    //...
  }
}

... then your activator instance should be like this:

// YourClass.php

class YourClass
{
    public function run()
    {
        // "myFeatureModel" is the content model type
        $activator = new ContentfulActivator($this->client, 'myFeatureModel', [
            'name' => 'featureName', // Field name for feature key
            'state' => 'isActive' // Field name for feature state
        ]);
        
        $manager = new FeatureManager($activator);
        if ($manager->isActive('your_feature_name')) {
            // do something
        }
    }
}

You can skip the field mapping (like the first example) if you use the default field names in contentful:

  • 'state' for the feature state field
  • 'name' for the feature key field

统计信息

  • 总下载量: 1.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固