yii2-module/yii2-information

处理原子信息单元的模块

安装次数: 2,228

依赖者: 1

建议者: 0

安全: 0

星标: 0

分支: 0

类型:yii2-module


README

处理原子信息单元的模块。

coverage build status

安装

此库的安装通过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。请参阅许可证文件