-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaManager.php
63 lines (53 loc) · 1.75 KB
/
MediaManager.php
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
<?php
/**
* Copyright (c) 2017. ProVision Media Group Ltd. <http://provision.bg>
* Venelin Iliev <http://veneliniliev.com>
*/
/*
* ProVision Administration, http://ProVision.bg
* Author: Venelin Iliev, http://veneliniliev.com
*/
namespace ProVision\MediaManager;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Lang;
class MediaManager
{
/**
* Array config for JS
* @param array $config
* @return array
*/
public static function config($config = [], $return = 'json')
{
/*
* Relation::morphMap fix
*/
if (!empty($config['filters']['mediaable_type'])) {
$type = array_search($config['filters']['mediaable_type'], Relation::morphMap());
if ($type) {
$config['filters']['mediaable_type'] = $type;
}
}
/*
* merge/replace configs
*/
$array = array_replace_recursive([
'routes' => [
'index' => \ProVision\Administration\Administration::route('media-manager.index'),
//'store' => \ProVision\Administration\Administration::route('media-manager.store'),
//'destroy' => \ProVision\Administration\Administration::route('media-manager.destroy', [0]),
],
'lang' => Lang::get('media-manager::admin'),
'languages' => \ProVision\Administration\Administration::getLanguages(),
'button' => [
'title' => trans('media-manager::admin.button_title'),
'class' => 'btn-warning',
'icon' => 'picture-o'
]
], $config);
if ($return == 'json') {
return json_encode($array);
}
return $array;
}
}