Skip to content

Commit b716277

Browse files
committed
Merge pull request #11 from ytake/feature-change-dependency
Feature change dependency
2 parents 132f10d + 03ec0eb commit b716277

68 files changed

Lines changed: 2335 additions & 544 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.scrutinizer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ filter:
33
- src/*
44
excluded_paths:
55
- tests/*
6+
- src/data/*
67
tools:
78
php_code_sniffer:
89
config:

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Yuuki Takezawa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Laravel-Aspect
2-
for laravel framework(use Go!Aop Framework)
2+
for laravel framework
33

44
[![Build Status](http://img.shields.io/travis/ytake/Laravel-Aspect/master.svg?style=flat-square)](https://travis-ci.org/ytake/Laravel-Aspect)
55
[![Coverage Status](http://img.shields.io/coveralls/ytake/Laravel-Aspect/master.svg?style=flat-square)](https://coveralls.io/r/ytake/Laravel-Aspect?branch=master)
@@ -13,7 +13,7 @@ for laravel framework(use Go!Aop Framework)
1313
[![Latest Version](http://img.shields.io/packagist/v/ytake/laravel-aspect.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-aspect)
1414
[![Total Downloads](http://img.shields.io/packagist/dt/ytake/laravel-aspect.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-aspect)
1515

16-
## usage
16+
## usage
1717

1818
### install
1919

@@ -41,6 +41,33 @@ $ composer require ytake/laravel-aspect
4141
]
4242
```
4343

44+
### publish aspect module class
45+
46+
```bash
47+
$ php artisan ytake:aspect-module-publish
48+
```
49+
more command options [--help]
50+
51+
### aspect kernel boot
52+
53+
added serviceProvider Class
54+
55+
```php
56+
class AppServiceProvider extends ServiceProvider
57+
{
58+
/**
59+
* @return void
60+
*/
61+
public function boot()
62+
{
63+
/** @var \Ytake\LaravelAspect\AspectManager $aspect */
64+
$aspect = $this->app['aspect.manager'];
65+
$aspect->register(\App\Modules\CacheableModule::class);
66+
}
67+
68+
}
69+
```
70+
4471
### publish configure
4572

4673
* basic
@@ -69,7 +96,7 @@ $ php artisan ytake:aspect-clear-cache
6996

7097
## Annotations
7198

72-
### @Transactional(Around Advice)
99+
### @Transactional
73100
for database transaction(illuminate/database)
74101

75102
* option
@@ -90,7 +117,7 @@ public function save(array $params)
90117
}
91118
```
92119

93-
### @Cacheable(After Advice)
120+
### @Cacheable
94121
for cache(illuminate/cache)
95122

96123
* option
@@ -118,7 +145,7 @@ public function namedMultipleKey($id, $value)
118145
}
119146
```
120147

121-
### @CacheEvict(After Advice)
148+
### @CacheEvict
122149
for cache(illuminate/cache) / remove cache
123150

124151
* option
@@ -144,7 +171,7 @@ public function removeCache()
144171
}
145172
```
146173

147-
### @CachePut(After Advice)
174+
### @CachePut
148175
for cache(illuminate/cache) / cache put
149176

150177
* option
@@ -169,23 +196,38 @@ public function throwExceptionCache()
169196
}
170197
```
171198

172-
## add Interceptors
199+
### @Loggable
200+
201+
soon
173202

174-
your service provider's
203+
### Annotation Cache Driver
204+
205+
chose array driver or file cache driver
206+
207+
use config/ytake-laravel-aspect.php file
175208

176209
```php
177-
public function boot()
178-
{
179-
$this->app['aspect.annotation.register']->registerAnnotations([
180-
app_path() . '/Annotation/Finder.php',
181-
]);
182-
183-
$this->app['aspect.manager']->setAspects([
184-
\App\Interceptor\SampleInterceptor::class
185-
]);
186-
}
210+
'annotation' => [
211+
/**
212+
* choose annotation reader
213+
* 'array'(default), 'file'(file cache)
214+
*/
215+
'default' => env('ASPECT_ANNOTATION_DRIVER', 'array'),
216+
217+
'drivers' => [
218+
'file' => [
219+
'cache_dir' => storage_path('framework/annotation'),
220+
//
221+
'debug' => env('ASPECT_ANNOTATION_DEBUG', true),
222+
],
223+
],
224+
],
187225
```
188226

227+
## add Interceptors
228+
229+
soon
230+
189231
## for testing
190232
use none driver
191233

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
],
1919
"require": {
2020
"php": ">=5.5.9",
21-
"goaop/framework": "~0.0",
2221
"illuminate/console": "~5.0",
2322
"illuminate/filesystem": "~5.0",
2423
"illuminate/support": "~5.0",
2524
"illuminate/config": "~5.0",
26-
"doctrine/annotations": "~1.0"
25+
"illuminate/contracts": "~5.0",
26+
"ray/aop": "~2.0",
27+
"doctrine/annotations": "~1.0",
28+
"doctrine/cache": "~1.0"
2729
},
2830
"require-dev": {
2931
"symfony/framework-bundle": "2.*",
@@ -41,7 +43,8 @@
4143
},
4244
"autoload-dev": {
4345
"files": [
44-
"tests/TestCase.php"
46+
"tests/TestCase.php",
47+
"tests/helper.php"
4548
],
4649
"psr-4": {
4750
"__Test\\": "tests/src"

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<directory>./src</directory>
2121
<exclude>
2222
<directory>./src/config</directory>
23+
<directory>./src/data</directory>
2324
<file>./src/AspectServiceProvider.php</file>
2425
<file>./src/CompileServiceProvider.php</file>
2526
<file>./src/ConsoleServiceProvider.php</file>

src/Annotation.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -7,18 +8,25 @@
78
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
910
* THE SOFTWARE.
11+
*
12+
* This software consists of voluntary contributions made by many individuals
13+
* and is licensed under the MIT license.
14+
* Copyright (c) 2015 Yuuki Takezawa
15+
*
16+
*
17+
* CodeGenMethod Class, CodeGen Class is:
18+
* Copyright (c) 2012-2015, The Ray Project for PHP
19+
*
20+
* @license http://opensource.org/licenses/bsd-license.php BSD
1021
*/
1122

1223
namespace Ytake\LaravelAspect;
1324

1425
use Doctrine\Common\Annotations\AnnotationRegistry;
26+
use Ytake\LaravelAspect\Exception\FileNotFoundException;
1527

1628
/**
1729
* Class Annotation
18-
*
19-
* @package Ytake\LaravelAspect
20-
* @author yuuki.takezawa<yuuki.takezawa@comnect.jp.net>
21-
* @license http://opensource.org/licenses/MIT MIT
2230
*/
2331
class Annotation
2432
{
@@ -34,16 +42,15 @@ public function registerAnnotations(array $files)
3442
}
3543

3644
/**
37-
* use annotations
38-
*
39-
* @return void
45+
* @throws FileNotFoundException
4046
*/
4147
public function registerAspectAnnotations()
4248
{
4349
foreach ($this->files as $file) {
44-
if (file_exists($file)) {
45-
AnnotationRegistry::registerFile($file);
50+
if (!file_exists($file)) {
51+
throw new FileNotFoundException($file);
4652
}
53+
AnnotationRegistry::registerFile($file);
4754
}
4855
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Transactional.php');
4956
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Cacheable.php');
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
* Copyright (c) 2015 Yuuki Takezawa
15+
*
16+
*
17+
* CodeGenMethod Class, CodeGen Class is:
18+
* Copyright (c) 2012-2015, The Ray Project for PHP
19+
*
20+
* @license http://opensource.org/licenses/bsd-license.php BSD
21+
*/
22+
23+
namespace Ytake\LaravelAspect\Annotation;
24+
25+
use Doctrine\Common\Annotations\Reader;
26+
27+
/**
28+
* Class AnnotationReaderTrait
29+
*/
30+
trait AnnotationReaderTrait
31+
{
32+
/** @var Reader */
33+
protected $reader;
34+
35+
/** @var string */
36+
protected $annotation;
37+
38+
/**
39+
* @param Reader $reader
40+
*/
41+
public function setReader(Reader $reader)
42+
{
43+
$this->reader = $reader;
44+
}
45+
46+
/**
47+
* @param string $annotation
48+
*/
49+
public function setAnnotation($annotation)
50+
{
51+
$this->annotation = $annotation;
52+
}
53+
}

src/Annotation/CacheEvict.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -7,6 +8,16 @@
78
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
910
* THE SOFTWARE.
11+
*
12+
* This software consists of voluntary contributions made by many individuals
13+
* and is licensed under the MIT license.
14+
* Copyright (c) 2015 Yuuki Takezawa
15+
*
16+
*
17+
* CodeGenMethod Class, CodeGen Class is:
18+
* Copyright (c) 2012-2015, The Ray Project for PHP
19+
*
20+
* @license http://opensource.org/licenses/bsd-license.php BSD
1021
*/
1122

1223
namespace Ytake\LaravelAspect\Annotation;
@@ -16,8 +27,6 @@
1627
/**
1728
* @Annotation
1829
* @Target("METHOD")
19-
* @author yuuki.takezawa<yuuki.takezawa@comnect.jp.net>
20-
* @license http://opensource.org/licenses/MIT MIT
2130
*/
2231
final class CacheEvict extends Annotation
2332
{

src/Annotation/CachePut.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -7,6 +8,16 @@
78
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
910
* THE SOFTWARE.
11+
*
12+
* This software consists of voluntary contributions made by many individuals
13+
* and is licensed under the MIT license.
14+
* Copyright (c) 2015 Yuuki Takezawa
15+
*
16+
*
17+
* CodeGenMethod Class, CodeGen Class is:
18+
* Copyright (c) 2012-2015, The Ray Project for PHP
19+
*
20+
* @license http://opensource.org/licenses/bsd-license.php BSD
1021
*/
1122

1223
namespace Ytake\LaravelAspect\Annotation;
@@ -16,8 +27,6 @@
1627
/**
1728
* @Annotation
1829
* @Target("METHOD")
19-
* @author yuuki.takezawa<yuuki.takezawa@comnect.jp.net>
20-
* @license http://opensource.org/licenses/MIT MIT
2130
*/
2231
final class CachePut extends Annotation
2332
{

0 commit comments

Comments
 (0)