maslosoft/gazebo

2.0.2 2022-10-06 16:45 UTC

This package is auto-updated.

Last update: 2024-09-06 20:57:56 UTC


README

Gazebo Logo Maslosoft Gazebo

插件容器

Latest Stable Version License Scrutinizer Code Quality Code Coverage

快速安装

composer require maslosoft/gazebo

文档

完整的Gazebo文档

插件容器

当开发应用程序的插件时,这些插件可能会有很大不同。这个库通过提供各种场景所需的实例化插件集来帮助管理插件。所有使用gazebo的组件的插件都配置为一个简单的列表,从而可以轻松添加和删除它们,无需担心插件类型应该放在哪里。

使用方法

//Plugins
class WaterPlugin implements WetInterface
{
	public $name = 'foo';
}
class MetalPlugin implements HardInterface
{
	public $options = false;
}
class GenericPlugin
{

}
// Config:
$config = [
			TestModel::class => [
				WaterPlugin::class,
				[
					'class' => MetalPlugin::class,
					'options' => true
				],
				GenericPlugin::class,
			],
		];

// Create plugins but only for selected interfaces
$plugins = (new PluginFactory())->instance($this->config, $model, [
			HardInterface::class,
			WetInterface::class
		]);


var_dump($plugins);

// Created flyweight instances of two plugins
//array(2) {
//	[0] => class Maslosoft\GazeboTest\Model\WaterPlugin#181 (1) {
//		public $name => string(3) "foo"
//	}
//	[1] => class Maslosoft\GazeboTest\Model\MetalPlugin#182 (2) {
//		public $options => bool(true)
//		public $class => string(38) "Maslosoft\GazeboTest\Model\MetalPlugin"
//	}
//}