thelia/thelia-studio-module 问题修复 & 功能扩展

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

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

thelia/thelia-studio-module

Composer 安装命令:

composer require thelia/thelia-studio-module

包简介

README 文档

README

author: Benjamin Perche bperche@openstudio.fr

This module allows you to generate all the repetitive classes and templates you have to write for a module.

  1. Installation

Install it as a thelia module by downloading the zip archive and extracting it in thelia/local/modules or by uploading it with the backoffice, or by requiring it with composer:

"require": {
    "thelia/thelia-studio-module": "~1.4.4"
}
  1. Usage

This module adds two commands: $ php Thelia module:generate:all and $ php Thelia module:generate:config-form

  1. Generating your module configuration form

To do that, you will need to write a new file. Create config-form.yml in your module's Config directory, and by respecting the following structure, TheliaStudio will generate everything for you :) :

  • the root node is called 'config'
  • then write your config varName: type for simple ones.
    • available types are: text, textarea, integer, number, checkbox.
    • you can add more precise data into the generation:
      • label: My Var to customize the name of the field displayed in the configuration page
      • required: false if the field isn't required
      • regex a validation regex.
      • size an array with "min" and "max" keys.
      • help: Help for my var a help message for the field displayed in the configuration page

Here's an example:

config:
  var_name: text
  var_name2: integer
  var_name3: checkbox
  var_name4:
    label: My Variable
    help: Help for variable ... 
    type:  text
    required: false
    regex: "a-z+"
    size:
      min: 5
      max: 20
  1. How to use it ?

### 4.1 Generate the configuration form only

First, write your config-form.yml Then launch $ php Thelia module:generate:config-form Finally, adapt the generated template for your need.

4.2 Generate table CRUD and configuration form

4.2.1 Writing the schema.xml

If you want your table to be correctly integrated into Thelia, you have to respect some conventions.

  • Always call your primary key id and never construct the PK with two columns.
  • If you want a visibility toggle, call your column visible and give it the type BOOLEAN or TINYINT
  • If you want a position management, call your column position. The order argument for the loop will be called manual
  • If the column is called 'id', 'title', 'name' or 'code' its entries in the table will be a clickable link
  • If the column is a BOOLEAN or a TINYINT type, it will be used as a checkbox.
  • If the column is called 'chapo', 'description' or 'postscriptum', it won't be displayed in the table

Here's a typical schema that will work like a charm with TheliaStudio:

<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="../../../../core/vendor/propel/propel/resources/xsd/database.xsd" >
    <table name="example_table" namespace="YourModule\Model">
        <column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
        <column defaultValue="0" name="visible" required="true" type="TINYINT" />
        <column defaultValue="0" name="position" required="true" type="INTEGER" />
        <column name="title" size="255" type="VARCHAR" />
        <column name="description" type="CLOB" />
        <column name="chapo" type="LONGVARCHAR" />
        <column name="postscriptum" type="LONGVARCHAR" />
        <behavior name="timestampable" />
        <behavior name="i18n">
            <parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
        </behavior>
        <behavior name="versionable">
            <parameter name="log_created_at" value="true" />
            <parameter name="log_created_by" value="true" />
        </behavior>
    </table>
    <external-schema filename="local/config/schema.xml" referenceOnly="true" />
</database>

4.2.2 Generating everything

Write your schema.xml, then if needed write your config-form.yml You can now launch $ php Thelia module:generate:all, your can use the --table option to specify the tables you want to generate.

Go to the Form directory and change the form names that you want. You can change the generated templates as you want, as the generator integrates everything, everywhere, even if it's not needed.

4.2.3 Automatic support for some standard Thelia features

The module will generate the appropriate code for managing 'position' and 'visible' fields if the table has columns with these names.

The module will automaticaly generate the code for managing standard Thelia SEO fields (including a rewriten URL) if the table has the following columns :

  • meta_title
  • meta_description
  • meta_keywords
  1. Access to the generated pages

The CRUDs are generated under /admin/module/ModuleCode/table_name You can write a hook to access it from the Tools dropdown or add links into your module configuration page.

thelia/thelia-studio-module 适用场景与选型建议

thelia/thelia-studio-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.85k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 thelia/thelia-studio-module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 thelia/thelia-studio-module 我们能提供哪些服务?
定制开发 / 二次开发

基于 thelia/thelia-studio-module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 7
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-01-14