Skip to content

Commit

Permalink
Merge pull request #826 from doctrine/fix-custom-template-configuration
Browse files Browse the repository at this point in the history
Fix XML configuration support for custom templates
  • Loading branch information
jwage authored Jun 6, 2019
2 parents 43280c1 + 46536ef commit 0e28a16
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 0e28a16

Please sign in to comment.