File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
lib/Doctrine/ODM/PHPCR/Mapping/Driver
tests/Doctrine/Tests/ODM/PHPCR/Mapping Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 2727use Doctrine \ODM \PHPCR \Mapping \ClassMetadata ;
2828use Doctrine \ODM \PHPCR \Mapping \MappingException ;
2929use Doctrine \Persistence \Mapping \ClassMetadata as PersistenceClassMetadata ;
30+ use Doctrine \Persistence \Mapping \Driver \ClassLocator ;
3031use Doctrine \Persistence \Mapping \Driver \ColocatedMappingDriver ;
3132use Doctrine \Persistence \Mapping \Driver \MappingDriver ;
3233
@@ -55,12 +56,17 @@ class AttributeDriver implements MappingDriver
5556 private AttributeReader $ reader ;
5657
5758 /**
58- * @param array<string> $paths
59+ * @param array<string>|ClassLocator $paths directory paths or class locator
5960 */
60- public function __construct (array $ paths )
61+ public function __construct (array | ClassLocator $ paths )
6162 {
6263 $ this ->reader = new AttributeReader ();
63- $ this ->addPaths ($ paths );
64+
65+ if ($ paths instanceof ClassLocator) {
66+ $ this ->classLocator = $ paths ;
67+ } else {
68+ $ this ->addPaths ($ paths );
69+ }
6470 }
6571
6672 public function isTransient ($ className ): bool
Original file line number Diff line number Diff line change 33namespace Doctrine \Tests \ODM \PHPCR \Mapping ;
44
55use Doctrine \ODM \PHPCR \Mapping \Driver \AttributeDriver ;
6+ use Doctrine \Persistence \Mapping \Driver \FileClassLocator ;
67use Doctrine \Persistence \Mapping \Driver \MappingDriver ;
78
89/**
910 * @group mapping
1011 */
1112class AttributeDriverTest extends AbstractMappingDriverTest
1213{
13- protected function loadDriver (): AttributeDriver
14+ /** @param list<string> $paths */
15+ protected function loadDriver (array $ paths = []): AttributeDriver
1416 {
15- return new AttributeDriver ([]);
17+ // Available in Doctrine Persistence 4.1+
18+ if (class_exists (FileClassLocator::class)) {
19+ $ paths = FileClassLocator::createFromDirectories ($ paths );
20+ }
21+
22+ return new AttributeDriver ($ paths );
1623 }
1724
1825 protected function loadDriverForTestMappingDocuments (): MappingDriver
1926 {
20- $ attributeDriver = $ this ->loadDriver ();
21- $ attributeDriver ->addPaths ([__DIR__ .'/Model ' ]);
22-
23- return $ attributeDriver ;
27+ return $ this ->loadDriver ([__DIR__ .'/Model ' ]);
2428 }
2529
2630 /**
You can’t perform that action at this time.
0 commit comments