Plugins container
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests/_output
.gitattributes
.gitignore
.scrunitizer.yml
.travis.yml
CHANGELOG.mkd
INSTALL.mkd
LICENSE-AGPL.mkd
LICENSE-COMMERCIAL-SAAS.mkd
LICENSE-COMMERCIAL-WEBSITE.mkd
README.mkd
UPGRADE.mkd
codeception.yml
composer.json
composer.lock
make-junctions.sh
make-toc
make-unit
model
push-tests
run-test
run-tests
run-tests-coverage
run-tests-hhvm
run-tests.bat
run-travis

README.mkd

Maslosoft Gazebo

Plugin container

Latest Stable Version License [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Maslosoft/Gazebo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Maslosoft/Gazebo/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/Maslosoft/Gazebo/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Maslosoft/Gazebo/?branch=master)

Quick Install

composer require maslosoft/gazebo

Usage

//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"
//	}
//}