mvenghaus/magento2-widget-directive
最新稳定版本:1.1.0
Composer 安装命令:
composer require mvenghaus/magento2-widget-directive
包简介
Simple parser & build for Magento 2 widget directives outside of the Magento environment.
README 文档
README
Simple parser & builder for Magento 2 widget directives outside of the Magento environment.
Installation
Install the package via composer:
composer require mvenghaus/magento2-widget-directive:"^1.0"
Usage
Parse directives from a string
$content = <<<EOF Lorem ipsum dolor sit amet, consetetur sadipscing elitr. {{widget type="TestWidget\Widget" param1="foo" param2="bar"}} Lorem ipsum dolor sit amet, consetetur sadipscing elitr. EOF; $widgetParser = new \Mvenghaus\Magento2WidgetDirective\WidgetParser(); $widgets = $widgetParser->parse($content); /** @var \Mvenghaus\Magento2WidgetDirective\Data\WidgetData $widget */ foreach ($widgets as $widget) { echo $widget->type; print_r($widget->properties); }
Building a directive
$widgetBuilder = new \Mvenghaus\Magento2WidgetDirective\WidgetBuilder(); $result = $widgetBuilder->build( new WidgetData( type: '\\TestWidget\\Widget', properties: [ 'param1' => 'foo', 'param2' => 'bar' ] ) ); // -> {{widget type="TestWidget\Widget" param1="foo" param2="bar"}}
Run Tests
composer test
统计信息
- 总下载量: 1.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-14