@@ -18,7 +18,7 @@ class DatatablesServiceProvider extends ServiceProvider {
18
18
*/
19
19
public function boot ()
20
20
{
21
- $ this ->package ('bllim/datatables ' );
21
+ $ this ->package ('bllim/datatables ' , ' datatables ' , __DIR__ );
22
22
}
23
23
24
24
/**
@@ -44,4 +44,36 @@ public function provides()
44
44
return array ('datatables ' );
45
45
}
46
46
47
+ /**
48
+ * Register the package's component namespaces.
49
+ *
50
+ * @param string $package
51
+ * @param string $namespace
52
+ * @param string $path
53
+ * @return void
54
+ */
55
+ public function package ($ package , $ namespace = null , $ path = null )
56
+ {
57
+
58
+ // Is it possible to register the config?
59
+ if (method_exists ($ this ->app ['config ' ], 'package ' )) {
60
+ $ this ->app ['config ' ]->package ($ package , $ path .'/config ' , $ namespace );
61
+ } else {
62
+ // Load the config for now..
63
+ $ config = $ this ->app ['files ' ]->getRequire ($ path .'/config/config.php ' );
64
+ foreach ($ config as $ key => $ value ){
65
+ $ this ->app ['config ' ]->set ($ namespace .':: ' .$ key , $ value );
66
+ }
67
+ }
68
+
69
+ // Register view files
70
+ $ appView = $ this ->app ['path ' ]."/views/packages/ {$ package }" ;
71
+ if ($ this ->app ['files ' ]->isDirectory ($ appView ))
72
+ {
73
+ $ this ->app ['view ' ]->addNamespace ($ namespace , $ appView );
74
+ }
75
+
76
+ $ this ->app ['view ' ]->addNamespace ($ namespace , $ path .'/views ' );
77
+ }
78
+
47
79
}
0 commit comments