oposs/silverstripe-structured-data 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

oposs/silverstripe-structured-data

Composer 安装命令:

composer require oposs/silverstripe-structured-data

包简介

Create, manage and validate structured yaml/json formatted text data

README 文档

README

Create, manage and validate structured yaml/json formatted text data and make it available through graphQL

Installation

Install through composer: composer require oposs/silverstripe-structured-data.

To enable the graphQL type, add the following lines to your app/_config/graphql.yml:

SilverStripe\GraphQL\Schema\Schema:
  schemas:
    default:
      src:
        - 'oposs/silverstripe-structured-data: _graphql'

If you just need a form field which can be validated against a JSON schema, you may want to disable the admin backend:

Oposs\StructuredData\Extensions\StructuredDataAdmin:
  show_admin_interface: false

Permissions

Global permissions provided by this module:

  • STRUCTURED_DATA_VIEW: Ability to view the Structured Data Module and stored data and schemas
  • STRUCTURED_DATA_ADMIN: Users holding this permission can edit/create/delete all data and schemas

Fine-grained control over editing access is possible by defining allowed groups for each data object individually.

Usage

Besides the possibility to access the data via graphQL this module also provides a specialized StructuredDataField which can be setup to validate it's input against a schema:

<?php
use Oposs\StructuredData\Form\StructuredDataField;
use Oposs\StructuredData\DataObjects\SchemaObject;
use SilverStripe\Control\Controller;

$SCHEMA_DUMMY = '{}';

TextAreaField::create('schema_field')
    ->setTitle('Schema for yaml_field');
    ->setReadonly(!Permission::check('SOME_SUPER_ADMIN_CAPABILITY'))

StructuredDataField::create('yaml_field')
    // Using a schema object
    ->setValidationSchemaName(SchemaObject::get('name')->first())
    // Using a string
    ->setValidationSchemaName($SCHEMA_DUMMY)
    // And the special case when the schema is configurable in the same form
    ->setValidationSchemaName(Controller::curr()->getRequest()->postVar('schema_field') ?? '{}')
    ->setTitle('Yaml Field');
   

GraphQL example

{
    "query": "{ readStructuredDatas(filter: {key: {eq: \"test-data\"}}) { nodes {  asJsonBlob   structured_data   }  }}"
}

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2022-11-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固