yii2-module / yii2-information
处理原子信息单元的模块
Requires
- php: >=8.0
- php-extended/php-basic-console-logger: ^7
- php-extended/php-information-interface: ^18.4
- php-extended/php-information-object: ^18.4
- php-extended/php-multiple-logger: ^7
- yii2-extended/yii2-module-metadata-object: ^7
- yii2-extended/yii2-psr3-logger-bridge: ^7
- yii2-module/yii2-module-helper: ^7
- yiisoft/yii2: ^2
Requires (Dev)
- dev-master
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.8
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.8.0
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-08-31 15:12:50 UTC
README
处理原子信息单元的模块。
安装
此库的安装通过composer进行,并且通过其自动加载器加载此库的所有类。
- 从他们的网站下载
composer.phar
。 - 然后运行以下命令将此库作为依赖项安装
php composer.phar install yii2-module/yii2-information ^7
基本用法
此模块需要在配置级别设置以下组件
- 'db_information' 应该是
\yii\db\Connection
如果您已经有数据库连接,可以使用以下技巧
'db_information' => function() { return \Yii::$app->get('db'); },
其中 'db' 是您的数据库连接的ID。
此模块需要在配置级别设置以下参数
- (无)
您还应该修改以下更改的yii应用程序配置
[
...
'modules' => [
...
'information' => [
'class' => 'Yii2Module\Yii2Information\InformationModule',
],
...
],
...
]
控制台API
控制台API使用以下命令,假设您的当前工作目录是yii(控制台)文件所在的目录,并且该模块的配置已命名为information
。
./yii information/process/delete-for-module --moduleId={{moduleId}}
此方法删除与给定ID的模块相关的所有信息表中的信息。
./yii information/process/module --moduleId={{moduleId}}
此方法解决存储在给定ID的模块的信息表中的所有记录。
./yii information/process/data --moduleId={{moduleId}}
此方法仅解决存储在给定ID的模块中的信息数据。
./yii information/process/relation --moduleId={{moduleId}}
此方法仅解决存储在给定ID的模块中的信息关系。
PHP API
在InformationModule
组件中可用的PHP API定义如下
use PhpExtended\Information\InformationVisitorInterface;
use PhpExtended\Information\LoggerInformationVisitor;
use Psr\Log\LoggerInterface;
getStorageHandler(Module $module, LoggerInterface $logger, boolean $checkBeforeInsert = false) : InformationVisitorInterface
此方法获取一个信息处理器来处理所有可能抛给它的信息。如果$checkBeforeInsert
参数设置为true,则此方法将使用另一个处理器装饰处理器,该处理器会在当前数据库中检查信息是否存在,如果存在,则跳过存储。该处理器不会检查信息的准确性,只检查其存在性。此处理器在多线程环境中更有用,因为它最大限度地并行化了解决记录。
use PhpExtended\Information\InformationVisitorInterface;
use PhpExtended\Information\LoggerInformationVisitor;
use Psr\Log\LoggerInterface;
getResolverHandler(Module $module, LoggerInterface $logger) : InformationVisitorInterface
此方法获取一个信息处理器来处理所有可能抛给它的信息。它将尝试像所有其他下面的process
方法一样解决它,如果无法解决,则像上面的存储处理器一样存储记录。此处理器在单线程环境中更有用,因为它最大限度地减少了数据库查询的数量。
processForModule(Module $module, LoggerInterface $logger = null) : void
此方法处理给定模块的所有类型的信息。在此上下文中,处理意味着将单个信息上下文解析为能够在针对它们量身定制的数据库中存储所有这些信息。所有无法相应存储的信息都保留在信息数据库中。
deleteForModule(Module $module) : void
此方法删除给定模块在信息表中的所有相关信息。
processInformationData(Module $module, LoggerInterface $logger = null) : void
此方法处理给定模块的所有数据类型信息。假设接收到的数据库包含一个 path
字段,用于存储信息的键或标识符。
processInformationRelation(Module $module, LoggerInterface $logger = null) : void
此方法处理给定模块的所有关系类型信息。假设接收到的数据库包含一个 path
字段,用于存储信息的键或标识符。
许可证
MIT。请参阅许可证文件。