-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathFileManagerServiceProvider.php
More file actions
97 lines (80 loc) · 3.39 KB
/
Copy pathFileManagerServiceProvider.php
File metadata and controls
97 lines (80 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Backpack\FileManager;
use Backpack\Basset\Facades\Basset;
use Backpack\CRUD\ViewNamespaces;
use Barryvdh\Elfinder\ElfinderController;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
class FileManagerServiceProvider extends ServiceProvider
{
protected $commands = [
Console\Commands\Install::class,
];
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
// Publishing is only necessary when using the CLI.
if ($this->app->runningInConsole()) {
$this->bootForConsole();
}
if (is_dir(base_path('resources/views/vendor/backpack/filemanager'))) {
$this->loadViewsFrom(base_path('resources/views/vendor/backpack/filemanager'), 'backpack.filemanager');
}
// Fallback to package views
$this->loadViewsFrom(__DIR__.'/../resources/views', 'backpack.filemanager');
$crudLanguages = array_keys(config('backpack.crud.languages', []));
foreach ($crudLanguages as $language) {
if ($language === 'en') {
continue;
}
Basset::map('bp-elfinder-i18n-'.$language, 'https://raw.githubusercontent.com/Studio-42/elFinder/refs/tags/2.1.64/js/i18n/elfinder.'.$language.'.js');
}
}
public function register()
{
$this->app->bind(ElfinderController::class, BackpackElfinderController::class);
// Add basset view path
Basset::addViewPath(realpath(__DIR__.'/../resources/views'));
ViewNamespaces::addFor('fields', [
'backpack.filemanager::fields',
]);
ViewNamespaces::addFor('columns', [
'backpack.filemanager::columns',
]);
}
/**
* Console-specific booting.
*
* @return void
*/
protected function bootForConsole()
{
// Publishing exclusively the elfinder files, not the columns and fields folders
$this->publishes([
__DIR__.'/../resources/views/elfinder.blade.php' => resource_path('views/vendor/backpack/filemanager/elfinder.blade.php'),
__DIR__.'/../resources/views/standalonepopup.blade.php' => resource_path('views/vendor/backpack/filemanager/standalonepopup.blade.php'),
__DIR__.'/../resources/views/common_scripts.blade.php' => resource_path('views/vendor/backpack/filemanager/common_scripts.blade.php'),
__DIR__.'/../resources/views/common_styles.blade.php' => resource_path('views/vendor/backpack/filemanager/common_styles.blade.php'),
], 'elfinder-views');
$this->publishes([
__DIR__.'/../resources/views/columns' => resource_path('views/vendor/backpack/filemanager/columns'),
], 'filemanager-columns');
$this->publishes([
__DIR__.'/../resources/views/fields' => resource_path('views/vendor/backpack/filemanager/fields'),
], 'filemanager-fields');
// Publishing config file.
$this->publishes([
__DIR__.'/../config/elfinder.php' => config_path('elfinder.php'),
], 'config');
// Registering package commands.
$this->commands($this->commands);
// Mapping the elfinder prefix, if missing
if (! Config::get('elfinder.route.prefix')) {
Config::set('elfinder.route.prefix', Config::get('backpack.base.route_prefix').'/elfinder');
}
}
}