forked from josh-taylor/sage-svg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsage-svg.php
37 lines (31 loc) · 1010 Bytes
/
sage-svg.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
<?php
namespace SageSvg;
use function App\sage;
use BladeUI\Icons\Factory;
use BladeUI\Icons\IconsManifest;
use Illuminate\Filesystem\Filesystem;
function registerBinding()
{
if (function_exists('\\App\\sage')) {
sage()->singleton(Factory::class, function () {
$factory = new Factory(new Filesystem(), new IconsManifest(new Filesystem(), './'));
$factory->add('default', [
'path' => get_stylesheet_directory().'/assets/icons/',
'prefix' => ''
]);
return $factory;
});
}
}
function registerBladeTag()
{
if (function_exists('\\App\\sage')) {
sage('blade')->compiler()->directive('svg', function ($expression) {
return "<?php echo e(\\App\\sage(\\BladeUI\\Icons\\Factory::class)->svg($expression)) ?>";
});
}
}
if (function_exists('add_action')) {
add_action('init', __NAMESPACE__.'\registerBinding');
add_action('init', __NAMESPACE__.'\registerBladeTag');
}