敏感/sensi-yaml-gui-bundle

一个简单的symfony2 yaml gui,允许您通过简单的网页表单编辑yaml配置文件。

dev-master / 1.0.x-dev 2016-02-19 18:55 UTC

This package is not auto-updated.

Last update: 2024-09-25 11:19:46 UTC


README

此包可以从给定的yaml配置文件生成一个简单的sonata admin仪表板网页表单。它也可以独立于SonataAdminBundle使用。

此包处于早期开发版本,所以请随意分支并为此包做出贡献。

安装

使用composer

$ php composer.phar require sensi/sensi-yaml-gui-bundle

在AppKernel中启用该包

// app/AppKernel.php
public function registerBundles()
{
    return array(
    // ...
    new Sensi\Bundle\YamlGuiBundle\SensiYamlGuiBundle(),
    // ...
    );
}

插入路由文件

# app/config/routing.yml
sensi_yaml_gui:
    resource: "@SensiYamlGuiBundle/Resources/config/routing.yml"
    prefix:   /yamlgui

创建并修改*app/config/yamlgui.yml并将其插入app/config.yml

# app/config/yamlgui.yml
sensi_yaml_gui:
	# Includes the sonata admin pool into the yaml gui (use sonata base template). 
	# Default value false.
	sonata_admin_modus: true

	# Path where the managed yaml config files were located
	# Notice you have to create the folder and make it writeable for the yamlgui writer
	config_root_dir: "%kernel.root_dir%/config/yamlgui/"   

	# List of all files which were available throw the yamlgui. Must be located in 
	# config_root_dir
	managed_files:
	  "demo.yml": { title: "Demo config" }

添加yamlgui.yml

# app/config/config.yml 
- { resource: yamlgui.yml }

(可选)配置Sonata Admin仪表板的块服务

# app/config/config.yml
sonata_block:
    blocks:
        sonata.block.service.sensi_yaml_gui:
            contexts: [admin]

sonata_admin:
    templates:
        layout: SonataAdminBundle::layout.html.twig
    dashboard:
        blocks:
            -
                position: left
                type: sonata.admin.block.admin_list
            -
                position: right
                type: sonata.block.service.sensi_yaml_gui

最后创建您的yaml配置文件,并在managed_files下添加它们。之后,可以通过在浏览器中调用以下路径来编辑这些文件:/yamlgui/list或/yamlgui/edit/{文件名}

翻译

如果您想将配置键标签翻译成可读的人名,您可以在app/Resources/translations/sensi_yaml_gui.<language_key>.yml中创建一个翻译文件。此文件可以扩展原始翻译文件,添加您自定义的翻译。