salesrender / plugin-component-info
SalesRender 插件信息组件
0.1.11
2024-08-09 15:02 UTC
Requires
- php: >=7.4
- ext-json: *
- xakepehok/enum-helper: ^0.1.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- salesrender/plugin-component-translations: ^0.1.2
README
\SalesRender\Plugin\Components\Info\Info
- 用于表示插件开发者信息的组件\SalesRender\Plugin\Components\Info\Developer
- 用于表示插件自身信息的组件
安装
composer require salesrender/plugin-component-info
配置
$type = new \SalesRender\Plugin\Components\Info\PluginType(PluginType::MACROS); //PluginPurpose shown only for example //@see https://github.com/salesrender/plugin-component-purpose $purpose = new PluginPurpose( new PluginClass(PluginClass::CLASS_EXPORTER), new PluginEntity(PluginEntity ::ENTITY_ORDER), ); $developer = new \SalesRender\Plugin\Components\Info\Developer( 'Tony Stark', 'support@starkindustries.com', 'starkindustries.com' ); $info = \SalesRender\Plugin\Components\Info\Info::config( $type, 'Excel', 'This plugin can be used for export your orders to Excel', $purpose, $developer ); //Info name and description also can be a callable $info = \SalesRender\Plugin\Components\Info\Info::config( $type, fn() => 'Excel', fn() => 'This plugin can be used for export your orders to Excel', $purpose, $developer );
使用
echo Info::getInstance()->getName(); //print "Excel", also for callable echo Info::getInstance()->getDescription(); //print "This plugin can be used for export your orders to Excel", also for callable $extra = Info::getInstance()->getExtra(); $developer = Info::getInstance()->getDeveloper(); echo json_encode(Info::getInstance()); //can be serialized into JSON