dev-think-one /
nova-flexible-content
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace NovaFlexibleContent; |
||||
| 4 | |||||
| 5 | use Illuminate\Support\Arr; |
||||
| 6 | use Illuminate\Support\Collection; |
||||
| 7 | use Laravel\Nova\Events\ServingNova; |
||||
| 8 | use Laravel\Nova\Nova; |
||||
| 9 | use NovaFlexibleContent\Http\FlexibleAttribute; |
||||
| 10 | use NovaFlexibleContent\Http\Middleware\InterceptFlexibleAttributes; |
||||
| 11 | |||||
| 12 | class ServiceProvider extends \Illuminate\Support\ServiceProvider |
||||
| 13 | { |
||||
| 14 | /** |
||||
| 15 | * Bootstrap any application services. |
||||
| 16 | * |
||||
| 17 | * @return void |
||||
| 18 | */ |
||||
| 19 | 38 | public function boot(): void |
|||
| 20 | { |
||||
| 21 | 38 | $this->addMiddleware(); |
|||
| 22 | |||||
| 23 | 38 | Nova::serving(function (ServingNova $event) { |
|||
|
0 ignored issues
–
show
|
|||||
| 24 | 9 | Nova::script('flexible-content-field', __DIR__ . '/../dist/js/field.js'); |
|||
| 25 | 9 | Nova::style('flexible-content-field', __DIR__ . '/../dist/css/field.css'); |
|||
| 26 | |||||
| 27 | 9 | Nova::provideToScript([ |
|||
| 28 | 9 | 'flexible-content-field.flexible-attribute-key-name' => FlexibleAttribute::REGISTER_FLEXIBLE_FIELD_NAME, |
|||
| 29 | 9 | 'flexible-content-field.file-indicator-prefix' => FlexibleAttribute::FILE_INDICATOR, |
|||
| 30 | 9 | 'flexible-content-field.group-separator' => FlexibleAttribute::GROUP_SEPARATOR, |
|||
| 31 | 9 | ]); |
|||
| 32 | 38 | }); |
|||
| 33 | |||||
| 34 | 38 | if ($this->app->runningInConsole()) { |
|||
| 35 | 38 | $this->publishes([ |
|||
| 36 | 38 | __DIR__ . '/../config/nova-flexible-content.php' => config_path('nova-flexible-content.php'), |
|||
| 37 | 38 | ], 'config'); |
|||
| 38 | |||||
| 39 | 38 | $this->commands([ |
|||
| 40 | 38 | \NovaFlexibleContent\Console\Commands\GenerateIdeHelperLayoutsCommand::class, |
|||
| 41 | 38 | ]); |
|||
| 42 | } |
||||
| 43 | |||||
| 44 | 38 | $this->registerCollectionMacros(); |
|||
| 45 | } |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * Register any application services. |
||||
| 49 | * |
||||
| 50 | * @return void |
||||
| 51 | */ |
||||
| 52 | 38 | public function register(): void |
|||
| 53 | { |
||||
| 54 | 38 | $this->mergeConfigFrom(__DIR__ . '/../config/nova-flexible-content.php', 'nova-flexible-content'); |
|||
| 55 | } |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * Adds required middleware for Nova requests. |
||||
| 59 | * |
||||
| 60 | * @return void |
||||
| 61 | */ |
||||
| 62 | 38 | public function addMiddleware(): void |
|||
| 63 | { |
||||
| 64 | 38 | $router = $this->app['router']; |
|||
| 65 | |||||
| 66 | 38 | if ($router->hasMiddlewareGroup('nova')) { |
|||
| 67 | 38 | $router->pushMiddlewareToGroup('nova', InterceptFlexibleAttributes::class); |
|||
| 68 | |||||
| 69 | 38 | return; |
|||
| 70 | } |
||||
| 71 | |||||
| 72 | if (!$this->app->configurationIsCached()) { |
||||
| 73 | config()->set('nova.middleware', array_merge( |
||||
| 74 | config('nova.middleware', []), |
||||
| 75 | [InterceptFlexibleAttributes::class] |
||||
| 76 | )); |
||||
| 77 | } |
||||
| 78 | } |
||||
| 79 | |||||
| 80 | 38 | protected function registerCollectionMacros(): void |
|||
| 81 | { |
||||
| 82 | 38 | Collection::macro('isAssoc', function () { |
|||
| 83 | return Arr::isAssoc($this->toBase()->all()); |
||||
|
0 ignored issues
–
show
The method
toBase() does not exist on NovaFlexibleContent\ServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 84 | 38 | }); |
|||
| 85 | } |
||||
| 86 | } |
||||
| 87 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.