liberty_code / module_model
Library
Requires
- php: ~7 || ~8
- liberty_code/di: ~1.0.0
- liberty_code/handle_model: ~1.0.0
- liberty_code/library: ~1.0.0
- liberty_code/model: ~1.0.0
Requires (Dev)
- liberty_code/validation: ~1.0.0
This package is auto-updated.
Last update: 2025-04-05 18:51:38 UTC
README
Description
Library contains modular model components, to split and use model components in several modules.
Requirement
- Script language: PHP: version 7 || 8
Installation
Several ways are possible:
Composer
Requirement
It requires composer installation. For more information: https://getcomposer.org
Command: Move in project root path
cd "<project_root_path>"
Command: Installation
php composer.phar require liberty_code/module_model ["<version>"]
Note
Include vendor
If project uses composer, vendor must be included:
require_once('<project_root_path>/vendor/autoload.php');
Configuration
Installation command allows to add, on composer file "/composer.json", following configuration:
{ "require": { "liberty_code/module_model": "<version>" } }
Include
Download
- Download following repository.
- Put it on repository root path.
Include source
require_once('<repository_root_path>/include/Include.php');
Usage
Entity module
Entity module contains part of configured attributes, can be used in configured entities.
Elements
EntityModule
Allows to design an entity module. Contains part of configured attributes, can be used in configured entities.
ValidatorEntityModule
Extends entity module features. Can be used in validator configured entities.
SaveEntityModule
Extends validator entity module features. Can be used in save configured entities.
EntityModuleCollection
Allows to design collection of entity modules. Uses list of entity modules, to build attributes configuration, for specified entity.
HandleValidatorEntityModule
Extends validator entity module features. Uses attribute provider, to build and manage its part of configured attributes.
HandleSaveEntityModule
Extends save entity module features. Uses attribute provider, to build and manage its part of configured attributes.
Builder
Allows to hydrate entity module collection, with entity modules.
FixBuilder
Extends entity module builder features. Uses fixed array of source data to hydrate entity module collection.
Example
// 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();
...
Entity
Module configured entity uses entity module collection, to manage its attributes.
Elements
ModuleConfigEntity
Extends configured entity features. Uses entity module collection, to manage its attributes.
ModuleValidatorConfigEntity
Extends validator configured entity features. Uses entity module collection, to manage its attributes.
ModuleSaveConfigEntity
Extends save configured entity features. Uses entity module collection, to manage its attributes.
Example
...
// 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
*/
...