Skip to content

Commit 86bfc84

Browse files
Vrtak-CZbeberlei
authored andcommitted
DDC-1247: Implement AnnotationDriver::addExcludePath
1 parent a2f4367 commit 86bfc84

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ abstract class AnnotationDriver implements MappingDriver
4848
*/
4949
protected $paths = array();
5050

51+
/**
52+
* The paths excluded from path where to look for mapping files.
53+
*
54+
* @var array
55+
*/
56+
protected $excludePaths = array();
57+
5158
/**
5259
* The file extension of mapping documents.
5360
*
@@ -107,7 +114,27 @@ public function getPaths()
107114
}
108115

109116
/**
110-
* Retrieves the current annotation reader.
117+
* Append exclude lookup paths to metadata driver.
118+
*
119+
* @param array $paths
120+
*/
121+
public function addExcludePaths(array $paths)
122+
{
123+
$this->excludePaths = array_unique(array_merge($this->excludePaths, $paths));
124+
}
125+
126+
/**
127+
* Retrieve the defined metadata lookup exclude paths.
128+
*
129+
* @return array
130+
*/
131+
public function getExcludePaths()
132+
{
133+
return $this->excludePaths;
134+
}
135+
136+
/**
137+
* Retrieve the current annotation reader
111138
*
112139
* @return AnnotationReader
113140
*/
@@ -194,6 +221,14 @@ public function getAllClassNames()
194221
foreach ($iterator as $file) {
195222
$sourceFile = realpath($file[0]);
196223

224+
foreach ($this->excludePaths as $excludePath) {
225+
$exclude = str_replace('\\', '/', realpath($excludePath));
226+
$current = str_replace('\\', '/', $sourceFile);
227+
if (strpos($current, $exclude) !== false) {
228+
continue 2;
229+
}
230+
}
231+
197232
require_once $sourceFile;
198233

199234
$includedFiles[] = $sourceFile;

0 commit comments

Comments
 (0)