1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace Eccube\Doctrine\ORM\Mapping\Driver; |
25
|
|
|
|
26
|
|
|
use Doctrine\Common\Persistence\Mapping\MappingException; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @package Eccube\Doctrine\ORM\Mapping\Driver |
30
|
|
|
*/ |
31
|
|
|
class AnnotationDriver extends \Doctrine\ORM\Mapping\Driver\AnnotationDriver |
32
|
|
|
{ |
33
|
|
|
protected $trait_proxies_directory; |
34
|
|
|
|
35
|
|
|
public function setTraitProxiesDirectory($dir) |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$this->trait_proxies_directory = $dir; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
*/ |
43
|
|
|
public function getAllClassNames() |
44
|
|
|
{ |
45
|
|
|
if ($this->classNames !== null) { |
46
|
|
|
return $this->classNames; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
if (!$this->paths) { |
|
|
|
|
50
|
|
|
throw MappingException::pathRequired(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$classes = []; |
54
|
|
|
$includedFiles = []; |
55
|
|
|
|
56
|
|
|
foreach ($this->paths as $path) { |
57
|
|
|
if ( ! is_dir($path)) { |
58
|
|
|
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$iterator = new \RegexIterator( |
62
|
|
|
new \RecursiveIteratorIterator( |
63
|
|
|
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), |
64
|
|
|
\RecursiveIteratorIterator::LEAVES_ONLY |
65
|
|
|
), |
66
|
|
|
'/^.+' . preg_quote($this->fileExtension) . '$/i', |
|
|
|
|
67
|
|
|
\RecursiveRegexIterator::GET_MATCH |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
foreach ($iterator as $file) { |
71
|
|
|
$sourceFile = $file[0]; |
72
|
|
|
|
73
|
|
|
if ( ! preg_match('(^phar:)i', $sourceFile)) { |
74
|
|
|
$sourceFile = realpath($sourceFile); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
foreach ($this->excludePaths as $excludePath) { |
78
|
|
|
$exclude = str_replace('\\', '/', realpath($excludePath)); |
79
|
|
|
$current = str_replace('\\', '/', $sourceFile); |
80
|
|
|
|
81
|
|
|
if (strpos($current, $exclude) !== false) { |
82
|
|
|
continue 2; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$proxyFile = str_replace($path, $this->trait_proxies_directory, $sourceFile); |
87
|
|
|
if (file_exists($proxyFile)) { |
88
|
|
|
require_once $proxyFile; |
89
|
|
|
|
90
|
|
|
$sourceFile = $proxyFile; |
91
|
|
|
} else { |
92
|
|
|
require_once $sourceFile; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$includedFiles[] = $sourceFile; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$declared = get_declared_classes(); |
100
|
|
|
|
101
|
|
View Code Duplication |
foreach ($declared as $className) { |
|
|
|
|
102
|
|
|
$rc = new \ReflectionClass($className); |
103
|
|
|
$sourceFile = $rc->getFileName(); |
104
|
|
|
if (in_array($sourceFile, $includedFiles) && ! $this->isTransient($className)) { |
105
|
|
|
$classes[] = $className; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$this->classNames = $classes; |
110
|
|
|
|
111
|
|
|
return $classes; |
112
|
|
|
} |
113
|
|
|
} |