wernerdweight/doctrine-xinclude-xml-driver-bundle

Symfony bundle providing XInclude support for XML mapping of Doctrine.

2.0.0 2023-02-21 18:09 UTC

This package is auto-updated.

Last update: 2024-04-21 20:46:01 UTC


README

Symfony bundle providing XInclude support for XML mapping of Doctrine.

Build Status Latest Stable Version Total Downloads License

Installation

1. Download using composer

composer require wernerdweight/doctrine-xinclude-xml-driver-bundle

2. Enable the bundle

Enable the bundle in your kernel:

    <?php
    // config/bundles.php
    return [
        // ...
        WernerDweight\DoctrineXIncludeXmlDriverBundle\DoctrineXIncludeXmlDriverBundle::class => ['all' => true],
    ];

Configuration

No configuration is required. This bundle automatically replaces the default XML driver with an XInclude-capable XML driver.

Usage

Add XInclude xmlns to the doctrine-mapping tag and you can then use xi:include tag to include mapping from other XML files. You can use xpointer to specify included parts of the linked XML file (see xpointer or browse stack overflow).

<!-- SomeEntity.orm.xml -->
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns:xi="http://www.w3.org/2001/XInclude" ...>
    <entity name="SomeEntity">
        <xi:include href="Deletable.trait.xml" parse="xml" xpointer="xpointer(//entity/*)"/>

        ...
    </entity>
</doctrine-mapping>

<!-- Deletable.trait.xml -->
<?xml version="1.0" encoding="utf-8"?>
<entity>
    <field name="deletedAt" type="datetime" />
    <many-to-one field="deletedBy" target-entity="User">
        <join-columns>
            <join-column name="deleted_by_id" referenced-column-name="id"/>
        </join-columns>
    </many-to-one>
</entity>

License

This bundle is under the MIT license. See the complete license in the root directiory of the bundle.