Skip to content

Commit

Permalink
Merge pull request #11 from ytake/feature-change-dependency
Browse files Browse the repository at this point in the history
Feature change dependency
  • Loading branch information
ytake committed Oct 23, 2015
2 parents 132f10d + 03ec0eb commit b716277
Show file tree
Hide file tree
Showing 68 changed files with 2,335 additions and 544 deletions.
1 change: 1 addition & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ filter:
- src/*
excluded_paths:
- tests/*
- src/data/*
tools:
php_code_sniffer:
config:
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Yuuki Takezawa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
78 changes: 60 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Laravel-Aspect
for laravel framework(use Go!Aop Framework)
for laravel framework

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

## usage
## usage

### install

Expand Down Expand Up @@ -41,6 +41,33 @@ $ composer require ytake/laravel-aspect
]
```

### publish aspect module class

```bash
$ php artisan ytake:aspect-module-publish
```
more command options [--help]

### aspect kernel boot

added serviceProvider Class

```php
class AppServiceProvider extends ServiceProvider
{
/**
* @return void
*/
public function boot()
{
/** @var \Ytake\LaravelAspect\AspectManager $aspect */
$aspect = $this->app['aspect.manager'];
$aspect->register(\App\Modules\CacheableModule::class);
}

}
```

### publish configure

* basic
Expand Down Expand Up @@ -69,7 +96,7 @@ $ php artisan ytake:aspect-clear-cache

## Annotations

### @Transactional(Around Advice)
### @Transactional
for database transaction(illuminate/database)

* option
Expand All @@ -90,7 +117,7 @@ public function save(array $params)
}
```

### @Cacheable(After Advice)
### @Cacheable
for cache(illuminate/cache)

* option
Expand Down Expand Up @@ -118,7 +145,7 @@ public function namedMultipleKey($id, $value)
}
```

### @CacheEvict(After Advice)
### @CacheEvict
for cache(illuminate/cache) / remove cache

* option
Expand All @@ -144,7 +171,7 @@ public function removeCache()
}
```

### @CachePut(After Advice)
### @CachePut
for cache(illuminate/cache) / cache put

* option
Expand All @@ -169,23 +196,38 @@ public function throwExceptionCache()
}
```

## add Interceptors
### @Loggable

soon

your service provider's
### Annotation Cache Driver

chose array driver or file cache driver

use config/ytake-laravel-aspect.php file

```php
public function boot()
{
$this->app['aspect.annotation.register']->registerAnnotations([
app_path() . '/Annotation/Finder.php',
]);

$this->app['aspect.manager']->setAspects([
\App\Interceptor\SampleInterceptor::class
]);
}
'annotation' => [
/**
* choose annotation reader
* 'array'(default), 'file'(file cache)
*/
'default' => env('ASPECT_ANNOTATION_DRIVER', 'array'),

'drivers' => [
'file' => [
'cache_dir' => storage_path('framework/annotation'),
//
'debug' => env('ASPECT_ANNOTATION_DEBUG', true),
],
],
],
```

## add Interceptors

soon

## for testing
use none driver

Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
],
"require": {
"php": ">=5.5.9",
"goaop/framework": "~0.0",
"illuminate/console": "~5.0",
"illuminate/filesystem": "~5.0",
"illuminate/support": "~5.0",
"illuminate/config": "~5.0",
"doctrine/annotations": "~1.0"
"illuminate/contracts": "~5.0",
"ray/aop": "~2.0",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.0"
},
"require-dev": {
"symfony/framework-bundle": "2.*",
Expand All @@ -41,7 +43,8 @@
},
"autoload-dev": {
"files": [
"tests/TestCase.php"
"tests/TestCase.php",
"tests/helper.php"
],
"psr-4": {
"__Test\\": "tests/src"
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<directory>./src</directory>
<exclude>
<directory>./src/config</directory>
<directory>./src/data</directory>
<file>./src/AspectServiceProvider.php</file>
<file>./src/CompileServiceProvider.php</file>
<file>./src/ConsoleServiceProvider.php</file>
Expand Down
25 changes: 16 additions & 9 deletions src/Annotation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -7,18 +8,25 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
* Copyright (c) 2015 Yuuki Takezawa
*
*
* CodeGenMethod Class, CodeGen Class is:
* Copyright (c) 2012-2015, The Ray Project for PHP
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*/

namespace Ytake\LaravelAspect;

use Doctrine\Common\Annotations\AnnotationRegistry;
use Ytake\LaravelAspect\Exception\FileNotFoundException;

/**
* Class Annotation
*
* @package Ytake\LaravelAspect
* @author yuuki.takezawa<[email protected]>
* @license http://opensource.org/licenses/MIT MIT
*/
class Annotation
{
Expand All @@ -34,16 +42,15 @@ public function registerAnnotations(array $files)
}

/**
* use annotations
*
* @return void
* @throws FileNotFoundException
*/
public function registerAspectAnnotations()
{
foreach ($this->files as $file) {
if (file_exists($file)) {
AnnotationRegistry::registerFile($file);
if (!file_exists($file)) {
throw new FileNotFoundException($file);
}
AnnotationRegistry::registerFile($file);
}
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Transactional.php');
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Cacheable.php');
Expand Down
53 changes: 53 additions & 0 deletions src/Annotation/AnnotationReaderTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
* Copyright (c) 2015 Yuuki Takezawa
*
*
* CodeGenMethod Class, CodeGen Class is:
* Copyright (c) 2012-2015, The Ray Project for PHP
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*/

namespace Ytake\LaravelAspect\Annotation;

use Doctrine\Common\Annotations\Reader;

/**
* Class AnnotationReaderTrait
*/
trait AnnotationReaderTrait
{
/** @var Reader */
protected $reader;

/** @var string */
protected $annotation;

/**
* @param Reader $reader
*/
public function setReader(Reader $reader)
{
$this->reader = $reader;
}

/**
* @param string $annotation
*/
public function setAnnotation($annotation)
{
$this->annotation = $annotation;
}
}
13 changes: 11 additions & 2 deletions src/Annotation/CacheEvict.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -7,6 +8,16 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
* Copyright (c) 2015 Yuuki Takezawa
*
*
* CodeGenMethod Class, CodeGen Class is:
* Copyright (c) 2012-2015, The Ray Project for PHP
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*/

namespace Ytake\LaravelAspect\Annotation;
Expand All @@ -16,8 +27,6 @@
/**
* @Annotation
* @Target("METHOD")
* @author yuuki.takezawa<[email protected]>
* @license http://opensource.org/licenses/MIT MIT
*/
final class CacheEvict extends Annotation
{
Expand Down
13 changes: 11 additions & 2 deletions src/Annotation/CachePut.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -7,6 +8,16 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
* Copyright (c) 2015 Yuuki Takezawa
*
*
* CodeGenMethod Class, CodeGen Class is:
* Copyright (c) 2012-2015, The Ray Project for PHP
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*/

namespace Ytake\LaravelAspect\Annotation;
Expand All @@ -16,8 +27,6 @@
/**
* @Annotation
* @Target("METHOD")
* @author yuuki.takezawa<[email protected]>
* @license http://opensource.org/licenses/MIT MIT
*/
final class CachePut extends Annotation
{
Expand Down
Loading

0 comments on commit b716277

Please sign in to comment.