Skip to content

Commit fcd8300

Browse files
committed
Merge pull request #37 from dirkluijk/simple-drivers
Add support for simplified YAML/XML drivers
2 parents a5b6ba8 + ce0e10a commit fcd8300

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ $app->register(new DoctrineOrmServiceProvider, array(
145145
"namespace" => "Bat\Entities",
146146
"path" => __DIR__."/src/Bat/Resources/mappings",
147147
),
148+
// As of 1.1, you can also use the simplified
149+
// XML/YAML driver (Symfony2 style)
150+
// Mapping files can be named like Foo.orm.yml
151+
// instead of Baz.Entities.Foo.dcm.yml
152+
array(
153+
"type" => "simple_yml",
154+
"namespace" => "Baz\Entities",
155+
"path" => __DIR__."/src/Bat/Resources/config/doctrine",
156+
),
148157
// Using PSR-0 namespaceish embedded resources
149158
// (requires registering a PSR-0 Resource Locator
150159
// Service Provider)
@@ -201,9 +210,11 @@ Configuration
201210

202211
Each mapping definition should be an array with the following
203212
options:
204-
* **type**: Mapping driver type, one of `annotation`, `xml`, `yml` or `php`.
213+
* **type**: Mapping driver type, one of `annotation`, `xml`, `yml`, `simple_xml`, `simple_yml` or `php`.
205214
* **namespace**: Namespace in which the entities reside.
206215

216+
*New: the `simple_xml` and `simple_yml` driver types were added in v1.1 and provide support for the [simplified XML driver][10] and [simplified YAML driver][11] of Doctrine.*
217+
207218
Additionally, each mapping definition should contain one of the
208219
following options:
209220
* **path**: Path to where the mapping files are located. This should
@@ -405,6 +416,8 @@ Some inspiration was also taken from [Doctrine Bundle][4] and
405416
[7]: https://packagist.org/packages/dflydev/doctrine-orm-service-provider
406417
[8]: https://github.com/Cilex/Cilex/blob/master/src/Cilex/Provider/DoctrineServiceProvider.php
407418
[9]: https://github.com/saxulum/saxulum-doctrine-orm-manager-registry-provider
419+
[10]: http://docs.doctrine-project.org/en/latest/reference/xml-mapping.html#simplified-xml-driver
420+
[11]: http://docs.doctrine-project.org/en/latest/reference/yaml-mapping.html#simplified-yaml-driver
408421

409422
[#dflydev]: irc://irc.freenode.net/#dflydev
410423
[#silex-php]: irc://irc.freenode.net/#silex-php

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v1.1.0-dev
2+
* @dirkluijk: Added support for simple YAML/XML drivers
3+
14
## v1.0.5 (2014-06-17)
25

36
* @c960657: Support remaining config options (#22)

src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
2929
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
3030
use Doctrine\ORM\Mapping\Driver\Driver;
31+
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
32+
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
3133
use Doctrine\ORM\Mapping\Driver\XmlDriver;
3234
use Doctrine\ORM\Mapping\Driver\YamlDriver;
3335
use Doctrine\ORM\Mapping\Driver\StaticPHPDriver;
@@ -168,10 +170,18 @@ public function register(\Pimple $app)
168170
$driver = new YamlDriver($entity['path']);
169171
$chain->addDriver($driver, $entity['namespace']);
170172
break;
173+
case 'simple_yml':
174+
$driver = new SimplifiedYamlDriver(array($entity['path'] => $entity['namespace']));
175+
$chain->addDriver($driver, $entity['namespace']);
176+
break;
171177
case 'xml':
172178
$driver = new XmlDriver($entity['path']);
173179
$chain->addDriver($driver, $entity['namespace']);
174180
break;
181+
case 'simple_xml':
182+
$driver = new SimplifiedXmlDriver(array($entity['path'] => $entity['namespace']));
183+
$chain->addDriver($driver, $entity['namespace']);
184+
break;
175185
case 'php':
176186
$driver = new StaticPHPDriver($entity['path']);
177187
$chain->addDriver($driver, $entity['namespace']);

0 commit comments

Comments
 (0)