File tree Expand file tree Collapse file tree 3 files changed +40
-9
lines changed
lib/Doctrine/ODM/PHPCR/Mapping/Driver
tests/Doctrine/Tests/ODM/PHPCR/Mapping Expand file tree Collapse file tree 3 files changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -40,3 +40,24 @@ parameters:
4040 message : " #^Call to an undefined method Doctrine\\\\ ODM\\\\ PHPCR\\\\ Query\\\\ Builder\\\\ AbstractNode\\ :\\ :setConverter\\ (\\ )\\ .$#"
4141 count : 1
4242 path : ../tests/Doctrine/Tests/ODM/PHPCR/Query/Builder/QueryBuilderTest.php
43+
44+ -
45+ message : ' #^Access to an undefined property Doctrine\\ODM\\PHPCR\\Mapping\\Driver\\AttributeDriver\:\:\$classLocator\.$#'
46+ identifier : property.notFound
47+ count : 1
48+ path : ../lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php
49+ reportUnmatched : false
50+
51+ -
52+ message : ' #^Class Doctrine\\Persistence\\Mapping\\Driver\\ClassLocator not found\.$#'
53+ identifier : class.notFound
54+ count : 1
55+ path : ../lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php
56+ reportUnmatched : false
57+
58+ -
59+ message : ' #^Parameter \$paths of method Doctrine\\ODM\\PHPCR\\Mapping\\Driver\\AttributeDriver\:\:__construct\(\) has invalid type Doctrine\\Persistence\\Mapping\\Driver\\ClassLocator\.$#'
60+ identifier : class.notFound
61+ count : 2
62+ path : ../lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php
63+ reportUnmatched : false
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