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 27
27
use Doctrine \ODM \PHPCR \Mapping \ClassMetadata ;
28
28
use Doctrine \ODM \PHPCR \Mapping \MappingException ;
29
29
use Doctrine \Persistence \Mapping \ClassMetadata as PersistenceClassMetadata ;
30
+ use Doctrine \Persistence \Mapping \Driver \ClassLocator ;
30
31
use Doctrine \Persistence \Mapping \Driver \ColocatedMappingDriver ;
31
32
use Doctrine \Persistence \Mapping \Driver \MappingDriver ;
32
33
@@ -55,12 +56,17 @@ class AttributeDriver implements MappingDriver
55
56
private AttributeReader $ reader ;
56
57
57
58
/**
58
- * @param array<string> $paths
59
+ * @param array<string>|ClassLocator $paths directory paths or class locator
59
60
*/
60
- public function __construct (array $ paths )
61
+ public function __construct (array | ClassLocator $ paths )
61
62
{
62
63
$ 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
+ }
64
70
}
65
71
66
72
public function isTransient ($ className ): bool
Original file line number Diff line number Diff line change 3
3
namespace Doctrine \Tests \ODM \PHPCR \Mapping ;
4
4
5
5
use Doctrine \ODM \PHPCR \Mapping \Driver \AttributeDriver ;
6
+ use Doctrine \Persistence \Mapping \Driver \FileClassLocator ;
6
7
use Doctrine \Persistence \Mapping \Driver \MappingDriver ;
7
8
8
9
/**
9
10
* @group mapping
10
11
*/
11
12
class AttributeDriverTest extends AbstractMappingDriverTest
12
13
{
13
- protected function loadDriver (): AttributeDriver
14
+ /** @param list<string> $paths */
15
+ protected function loadDriver (array $ paths = []): AttributeDriver
14
16
{
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 );
16
23
}
17
24
18
25
protected function loadDriverForTestMappingDocuments (): MappingDriver
19
26
{
20
- $ attributeDriver = $ this ->loadDriver ();
21
- $ attributeDriver ->addPaths ([__DIR__ .'/Model ' ]);
22
-
23
- return $ attributeDriver ;
27
+ return $ this ->loadDriver ([__DIR__ .'/Model ' ]);
24
28
}
25
29
26
30
/**
You can’t perform that action at this time.
0 commit comments