Completed
Push — master ( e214ab...401ef4 )
by yuuki
02:09
created

AspectServiceProvider::compiles()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 0
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-2017 Yuuki Takezawa
16
 *
17
 */
18
namespace Ytake\LaravelAspect;
19
20
use Illuminate\Support\ServiceProvider;
21
22
/**
23
 * Class AspectServiceProvider
24
 */
25
class AspectServiceProvider extends ServiceProvider
26
{
27
    /** @var bool */
28
    protected $defer = false;
29
30
    /**
31
     * boot aspect kernel
32
     */
33
    public function boot()
34
    {
35
        $this->app['aspect.manager']->weave();
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function register()
42
    {
43
        /**
44
         * for package configure
45
         */
46
        $configPath = __DIR__ . '/config/ytake-laravel-aop.php';
47
        $this->mergeConfigFrom($configPath, 'ytake-laravel-aop');
48
        $this->publishes([$configPath => config_path('ytake-laravel-aop.php')], 'aspect');
49
50
        $this->app->singleton('aspect.manager', function ($app) {
51
            $annotationConfiguration = new AnnotationConfiguration(
52
                $app['config']->get('ytake-laravel-aop.annotation')
53
            );
54
            $annotationConfiguration->ignoredAnnotations();
55
56
            // register annotation
57
            return new AspectManager($app);
58
        });
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function provides()
65
    {
66
        return [
67
            'aspect.manager',
68
        ];
69
    }
70
}
71