|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
5
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
6
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
7
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
8
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
9
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
10
|
|
|
* THE SOFTWARE. |
|
11
|
|
|
* |
|
12
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
13
|
|
|
* and is licensed under the MIT license. |
|
14
|
|
|
* |
|
15
|
|
|
* Copyright (c) 2015-2016 Yuuki Takezawa |
|
16
|
|
|
* |
|
17
|
|
|
*/ |
|
18
|
|
|
namespace Ytake\LaravelAspect; |
|
19
|
|
|
|
|
20
|
|
|
use Illuminate\Support\Manager; |
|
21
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class AnnotationManager |
|
25
|
|
|
* @method \Doctrine\Common\Annotations\Reader getReader() getReader |
|
26
|
|
|
*/ |
|
27
|
|
|
class AnnotationManager extends Manager |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* default annotation reader(no caching other than in memory [in php arrays]) |
|
31
|
|
|
* @return string |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getDefaultDriver() |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->app['config']->get('ytake-laravel-aop.annotation.default'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return ArrayReader |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function createArrayDriver() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->ignoredAnnotations($this->app['config']->get('ytake-laravel-aop.annotation.ignores', [])); |
|
44
|
|
|
return new ArrayReader(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return FileReader |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function createFileDriver() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->ignoredAnnotations($this->app['config']->get('ytake-laravel-aop.annotation.ignores', [])); |
|
53
|
|
|
return new FileReader($this->getConfigure('file')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param string $driver |
|
58
|
|
|
* @return string[] |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getConfigure($driver) |
|
61
|
|
|
{ |
|
62
|
|
|
$annotationConfigure = $this->app['config']->get('ytake-laravel-aop.annotation.drivers'); |
|
63
|
|
|
|
|
64
|
|
|
return $annotationConfigure[$driver]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Add a new annotation to the globally ignored annotation names with regard to exception handling. |
|
69
|
|
|
* @param array $ignores |
|
70
|
|
|
*/ |
|
71
|
|
|
private function ignoredAnnotations(array $ignores = []) |
|
72
|
|
|
{ |
|
73
|
|
|
foreach ($ignores as $ignore) { |
|
74
|
|
|
AnnotationReader::addGlobalIgnoredName($ignore); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|