mvenghaus/magento2-widget-directive 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-14