manzadey / sbuilder-xml-soap
SBuilder XML Generator for SOAP Client
Fund package maintenance!
Open Collective
Requires
- php: ^8.1
- ext-dom: *
- ext-soap: *
Requires (Dev)
- phpunit/phpunit: 10
- symfony/var-dumper: 6.3.x-dev
This package is auto-updated.
Last update: 2024-10-26 14:27:35 UTC
README
Пакет представляет собой простое API для генерации и выгрузки данных в формате XML в CMS SBuilder.
Установка
composer require manzadey/sbuilder-xml-soap
Создание структуры XML файла
use Manzadey\SBuilderXmlSoap\Plugins; use Manzadey\SBuilderXmlSoap\Plugin; use Manzadey\SBuilderXmlSoap\Category; use Manzadey\SBuilderXmlSoap\Field; use Manzadey\SBuilderXmlSoap\Element; $plugins = new Plugins; $plugin14 = new Plugin('pl_plugin_14'); $category1400 = new Category('1400'); $category1400->addField('cat_title', 'Раздел 1'); $category1400->addField(new Field('user_f_17', 'Наполнение для поля user_f_17')); $category1400->addField( static fn(Category $category) : Field => $category ->newField('user_f_19', 'Наполнение для поля user_f_19') ); $element = new Element; $element->addField('p_title', 'Элемент 1'); $element->addField('p_price1', '10000'); $element->addField('p_active', '1'); $element->addField('user_f_18', 'Наполнение для поля user_f_18'); $category1400->addElement($element); $category1400->addCategory( static fn(Category $category) : Category => $category->newCategory() ->addField('cat_title', 'Подраздел раздела 1') ->addField('user_f_17', 'Наполнение для поля user_f_17') ->addField('user_f_19', 'Наполнение для поля user_f_19') ->addElement(static fn(Category $category) : Element => $category ->newElement() ->addField('p_title', 'Элемент 2') ->addField('p_price1', '20000') ->addField('p_active', '1') ->addField('user_f_18', 'Наполнение для поля user_f_18') ->addField(static fn(Element $element) : Field => $element ->newField('user_f_4', '5') ->extId() ) ) ); $plugin14->addCategory($category1400); $plugins->addPlugin($plugin14); echo $plugins->save();
Создание структуры вместе со справочником
use Manzadey\SBuilderXmlSoap\Plugins; use Manzadey\SBuilderXmlSoap\Plugin; use Manzadey\SBuilderXmlSoap\Category; use Manzadey\SBuilderXmlSoap\Field; use Manzadey\SBuilderXmlSoap\Element; $plugins = (new Plugins)->addPlugin( static fn(Plugins $plugins) : Plugin => $plugins->newPlugin('pl_plugin_14') ->addCategory( static fn(Plugin $plugin) : Category => $plugin->newCategory() ->addField('cat_title', 'Новинки') ->addElement( static fn(Category $category) : Element => $category->newElement() ->addField('p_title', 'Мобильный телефон') ->addField('p_price_1', '10000') ->addField( static fn(Element $element) : Field => $element->newField('user_f_22', '4')->extId() ) ) ) )->newPlugin( 'pl_sprav', static fn(Plugin $plugin) : Plugin => $plugin->addCategory( static fn(Plugin $plugin) : Category => $plugin->newCategory() ->addField('cat_title', 'Цвета') ->addField('show_prop1', '1') ->addField('show_prop2', '0') ->addField('show_prop3', '0') ->addElement( static fn(Category $category) : Element => $category->newElement() ->addField('s_title', 'Красный') ->addField('s_prop_1', 'red') ->addField('s_ext_id', '4') )->addElement( static fn(Category $category) : Element => $category->newElement(extId: 5) ->addField('s_title', 'Зеленый') ->addField('s_prop_1', 'green') ->addField('s_ext_id', '5') ) ) );
Удаление элементов
use Manzadey\SBuilderXmlSoap\Plugins; use Manzadey\SBuilderXmlSoap\Plugin; use Manzadey\SBuilderXmlSoap\Category; use Manzadey\SBuilderXmlSoap\Element; $plugins = (new Plugins)->addPlugin( static fn(Plugins $plugins) : Plugin => $plugins ->newPlugin('pl_plugin_14') ->addCategory(static fn(Plugin $plugin) : Category => $plugin ->newCategory('2175') ->delete() ->addField('cat_title', 'Новинки') ->addElement( static fn(Category $category) : Element => $category ->newElement(extId: 12) ->addField('p_title', 'Мобильный телефон') ) ) ); echo $plugins->save();
Загрузка данных
$plugins->upload('https://url.to/soap/client', 'token');
Changelog
Please see CHANGELOG for more information on what has changed recently.
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.