basilicom / xml-tool-bundle
This Bundle provides xml (export) tools for Pimcore.
Installs: 224
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 2
Open Issues: 0
Type:pimcore-bundle
Requires
- pimcore/pimcore: >=5.0 <7.0
- spatie/array-to-xml: ^2.12
Requires (Dev)
- codeception/codeception: ^2.2
Suggests
- ext-xsl: Needed to support XSLT transformations via --xslt option
This package is auto-updated.
Last update: 2024-12-29 06:46:15 UTC
README
Adds commands for dealing with XML data. For now, parts of the Object tree can be exported recursively, retaining the hierarchy.
Exports can be triggered by a console command and written to stdout, a file or an pimcore asset.
If enabled, exports can be made available via a REST API, too.
Table of contents
License
GPLv3 - see: LICENSE
Requirements
- PHP >= 7.1
- Pimcore >= 5.0.0
- XSL PHP extension for --xslt option support
Installation
- Install the bundle using composer
composer require basilicom/xml-tool-bundle dev-master
. - Execute
bin/console pimcore:bundle:enable BasilicomXmlToolBundle
Configuration
n/a
Console Usage
Use the export command to export command to export
the Object tree, example for path /foo
:
bin/console basilicom:xmltool:export /foo
Example output:
Note: The Object tree /foo
contains in the example a single Object of
the Object Class Bar
with a single Input property of name
.
Exporting tree of Objects starting at /foo
<?xml version="1.0"?>
<root id="1" type="folder" key="" class="Folder">
<:children>
<Bar id="4" type="object" key="baaaar" class="Bar">
<name><![CDATA[bar]]></name>
</Bar>
</:children>
</root>
Complex example:
- do not export the attributes / fields of objects attached via relations
- export variants of objects, too
- change the name of the root node to 'Products'
- apply a sample xslt
- export to a pimcore asset
/output/my-export.xml
./bin/console basilicom:xmltool:export --omit-relation-object-fields --include-variants --root=products --asset=/output/my-export.xml --xslt sample.xsl /exp
Sample XSLT:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <objects> <xsl:for-each select="//Leaf"> <object> <name><xsl:value-of select="name"/></name> </object> </xsl:for-each> </objects> </xsl:template> </xsl:stylesheet>
For all options (writing to a file, etc.), see:
bin/console basilicom:xmltool:export --help
Usage: REST API
In order to enable the REST API, place a configuration file in app/config/local/xmltool.yml
:
basilicom_xml_tool: api: enabled: true endpoints: test1: token: secrettoken0815 root: Products # Root name of the exported XML file path: /export/products # Path to the exporting objects xslt: ../sample.xsl include_variants: true omit_relation_object_fields: true test2: path: /sample/obj/path
This example enables two endpoint URLs:
- https://PIMCORE-SERVER/xml-tool/export/test1?token=secrettoken0815
- https://PIMCORE-SERVER/xml-tool/export/test2
Limitations
Only a few field types are supported for now:
- input
- select
- wysiwyg
- textarea
- date
- datetime
- ManyToManyObjectRelation
- color
- rgbaColor
- localizedFields
To extend the supported types, implement a
getForType*
method in Service/Xml.php
.