@@ 21-49 (lines=29) @@ | ||
18 | * |
|
19 | * @author Kévin Dunglas <[email protected]> |
|
20 | */ |
|
21 | class AnnotationDirectoryLoader extends BaseAnnotationDirectoryLoader |
|
22 | { |
|
23 | private $scannedDirectories; |
|
24 | ||
25 | public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, array $scannedDirectories) |
|
26 | { |
|
27 | parent::__construct($locator, $loader); |
|
28 | ||
29 | $this->scannedDirectories = $scannedDirectories; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * {@inheritdoc} |
|
34 | */ |
|
35 | public function supports($resource, $type = null) |
|
36 | { |
|
37 | if (!parent::supports($resource, $type)) { |
|
38 | return false; |
|
39 | } |
|
40 | ||
41 | try { |
|
42 | $path = $this->locator->locate($resource); |
|
43 | } catch (\Exception $e) { |
|
44 | return false; |
|
45 | } |
|
46 | ||
47 | return isset($this->scannedDirectories[rtrim($path, '/')]); |
|
48 | } |
|
49 | } |
|
50 |
@@ 21-49 (lines=29) @@ | ||
18 | * |
|
19 | * @author Kévin Dunglas <[email protected]> |
|
20 | */ |
|
21 | class AnnotationFileLoader extends BaseAnnotationFileLoader |
|
22 | { |
|
23 | private $scannedDirectories; |
|
24 | ||
25 | public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, array $scannedDirectories) |
|
26 | { |
|
27 | parent::__construct($locator, $loader); |
|
28 | ||
29 | $this->scannedDirectories = $scannedDirectories; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * {@inheritdoc} |
|
34 | */ |
|
35 | public function supports($resource, $type = null) |
|
36 | { |
|
37 | if (!parent::supports($resource, $type)) { |
|
38 | return false; |
|
39 | } |
|
40 | ||
41 | try { |
|
42 | $path = $this->locator->locate($resource); |
|
43 | } catch (\Exception $e) { |
|
44 | return false; |
|
45 | } |
|
46 | ||
47 | return isset($this->scannedDirectories[dirname($path)]); |
|
48 | } |
|
49 | } |
|
50 |