Skip to content

Commit

Permalink
Fix XML configuration support for custom templates
Browse files Browse the repository at this point in the history
This functionality has been added on previous versions but it seems we
forgot to expose the configuration options for XML.
  • Loading branch information
lcobucci committed Jun 6, 2019
1 parent 43280c1 commit 46536ef
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<xs:complexType>
<xs:all minOccurs="0">
<xs:element type="xs:string" name="name" minOccurs="0" maxOccurs="1"/>
<xs:element type="xs:string" name="custom-template" minOccurs="0" maxOccurs="1"/>
<xs:element type="xs:string" name="migrations-namespace" minOccurs="0" maxOccurs="1"/>
<xs:element name="table" minOccurs="0" maxOccurs="1">
<xs:complexType>
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/Migrations/Configuration/XmlConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ protected function doLoad(string $file) : void
$config['name'] = (string) $xml->name;
}

if (isset($xml->{'custom-template'})) {
$config['custom_template'] = (string) $xml->{'custom-template'};
}

if (isset($xml->table['name'])) {
$config['table_name'] = (string) $xml->table['name'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ public function testVersionsOrganizationInvalid() : void
$this->loadConfiguration('organize_invalid');
}

public function testCustomTemplate() : void
{
$config = $this->loadConfiguration('custom_template');

self::assertSame('template.tpl', $config->getCustomTemplate());
}

public function testVersionsOrganizationIncompatibleFinder() : void
{
$this->expectException(MigrationException::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"custom_template" : "template.tpl"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

declare(strict_types=1);

return ['custom_template' => 'template.tpl'];
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-migrations xmlns="http://doctrine-project.org/schemas/migrations/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration
http://doctrine-project.org/schemas/migrations/configuration.xsd">

<custom-template>template.tpl</custom-template>
</doctrine-migrations>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
custom_template: "template.tpl"

0 comments on commit 46536ef

Please sign in to comment.