GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#688)
by
unknown
18:52
created

createLocalViewFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0013

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 9
cp 0.8889
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1.0013
1
<?php
2
3
namespace SleepingOwl\Admin\Providers;
4
5
use Illuminate\View\Factory;
6
use SleepingOwl\Admin\Admin;
7
use Illuminate\View\FileViewFinder;
8
use Illuminate\View\Engines\PhpEngine;
9
use Illuminate\View\Engines\EngineResolver;
10
11
class SleepingOwlServiceProvider extends AdminSectionsServiceProvider
12
{
13 285
    public function register()
14
    {
15 285
        $this->mergeConfigFrom(__DIR__.'/../../config/sleeping_owl.php', 'sleeping_owl');
16 285
        $this->loadViewsFrom(__DIR__.'/../../resources/views', 'sleeping_owl');
17
18 285
        $this->registerCore();
19 285
        $this->registerCommands();
20 285
    }
21
22
    /**
23
     * @param Admin $admin
24
     */
25 285
    public function boot(Admin $admin)
26
    {
27 285
        $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'sleeping_owl');
28
29 285
        if ($this->app->runningInConsole()) {
30 285
            $this->publishes([
31 285
                __DIR__.'/../../public' => public_path('packages/sleepingowl/'),
32 285
            ], 'assets');
33
34 285
            $this->publishes([
35 285
                __DIR__.'/../../config/sleeping_owl.php' => config_path('sleeping_owl.php'),
36 285
            ], 'config');
37 285
        }
38
39 285
        parent::boot($admin);
40 285
    }
41
42 285
    protected function registerCore()
43
    {
44 285
        $this->app->instance('sleeping_owl', $admin = new Admin($this->app));
45 285
        $admin->setTemplate($this->app['sleeping_owl.template']);
46 285
    }
47
48
    /**
49
     * @return Factory
50
     */
51 285
    private function createLocalViewFactory()
52
    {
53 285
        $resolver = new EngineResolver();
54
        $resolver->register('php', function () {
55
            return new PhpEngine();
56 285
        });
57 285
        $finder = new FileViewFinder($this->app['files'], [__DIR__.'/../../resources/views']);
58 285
        $factory = new Factory($resolver, $finder, $this->app['events']);
59 285
        $factory->addExtension('php', 'php');
60
61 285
        return $factory;
62 285
    }
63
64 285
    protected function registerCommands()
65
    {
66 285
        if ($this->app->runningInConsole()) {
67 285
            $this->commands([
68 285
                \SleepingOwl\Admin\Console\Commands\InstallCommand::class,
69 285
                \SleepingOwl\Admin\Console\Commands\UpdateCommand::class,
70 285
                \SleepingOwl\Admin\Console\Commands\UserManagerCommand::class,
71 285
                \SleepingOwl\Admin\Console\Commands\SectionGenerate::class,
72 285
                \SleepingOwl\Admin\Console\Commands\SectionMake::class,
73 285
                \SleepingOwl\Admin\Console\Commands\SectionProvider::class,
74 285
            ]);
75
76 285
            $localViewFactory = $this->createLocalViewFactory();
77 285
            $this->app->singleton(
78 285
                'command.sleepingowl.ide.generate',
79
                function ($app) use ($localViewFactory) {
80
                    return new \SleepingOwl\Admin\Console\Commands\GeneratorCommand($app['config'], $app['files'], $localViewFactory);
81
                }
82 285
            );
83
84 285
            $this->commands('command.sleepingowl.ide.generate');
85 285
        }
86 285
    }
87
}
88