liberty_code/module_model

v1.0.0 2023-09-19 20:09 UTC

This package is auto-updated.

Last update: 2024-09-19 22:34:09 UTC


README

描述

库包含模块化模型组件,用于在多个模块中拆分和使用模型组件。

需求

  • 脚本语言:PHP:版本 7 || 8

安装

有几种可能的方式

Composer

  1. 需求

    它需要安装 composer。更多信息: https://getcomposer.org

  2. 命令:移动到项目根路径

     cd "<project_root_path>"
    
  3. 命令:安装

     php composer.phar require liberty_code/module_model ["<version>"]
    
  4. 注意

    • 包含 vendor

      如果项目使用 composer,必须包含 vendor

        require_once('<project_root_path>/vendor/autoload.php');
      
    • 配置

      安装命令允许在 composer 文件中添加:

        {
            "require": {
                "liberty_code/module_model": "<version>"
            }
        }
      

包含

  1. 下载

    • 下载以下仓库。
    • 将其放在仓库根路径上。
  2. 包含源代码

     require_once('<repository_root_path>/include/Include.php');
    

用法

实体模块

实体模块包含配置属性的一部分,可以在配置的实体中使用。

元素

  • EntityModule

    允许设计实体模块。包含配置属性的一部分,可以在配置的实体中使用。

  • ValidatorEntityModule

    扩展实体模块功能。可以在配置的验证实体中使用。

  • SaveEntityModule

    扩展验证实体模块功能。可以在配置的保存实体中使用。

  • EntityModuleCollection

    允许设计实体模块集合。使用实体模块列表,为指定实体构建属性配置。

  • HandleValidatorEntityModule

    扩展验证实体模块功能。使用属性提供者,构建和管理其配置属性的一部分。

  • HandleSaveEntityModule

    扩展保存实体模块功能。使用属性提供者,构建和管理其配置属性的一部分。

  • Builder

    允许使用实体模块填充实体模块集合。

  • FixBuilder

    扩展实体模块构建器功能。使用固定数组的数据源来填充实体模块集合。

示例

// Get entity module collection
use liberty_code\module_model\entity_module\model\DefaultEntityModuleCollection;
$entityModuleCollection = new DefaultEntityModuleCollection();
...
// Set entity modules
use liberty_code\module_model\entity_module\model\DefaultEntityModule;
$entityModuleCollection->setTabEntityModule(DefaultEntityModule[...]);
...
// Get entity attribute configuration, from entity modules
$entityModuleCollection->getTabAttributeConfig();
...

实体

配置模块实体使用实体模块集合来管理其属性。

元素

  • ModuleConfigEntity

    扩展配置实体功能。使用实体模块集合来管理其属性。

  • ModuleValidatorConfigEntity

    扩展验证配置实体功能。使用实体模块集合来管理其属性。

  • ModuleSaveConfigEntity

    扩展保存配置实体功能。使用实体模块集合来管理其属性。

示例

...
// Get new entity
use liberty_code\module_model\entity\model\ModuleConfigEntity
$moduleConfigEntity = new ModuleConfigEntity($entityModuleCollection);
...
if($moduleConfigEntity->checkAttributeValid()) {
    $tabAttributeKey = $moduleConfigEntity->getTabAttributeKey();
    foreach($tabAttributeKey as $attributeKey) {
        echo($moduleConfigEntity->$attributeKey . '<br />');
    }
}
/**
 * Show: 
 * Entity attribute 1 value
 * ...
 * Entity attribute N value
 */
...