]> BookStack Code Mirror - bookstack/blobdiff - app/helpers.php
Merge bugfixes from branch 'v0.14'
[bookstack] / app / helpers.php
index e68e29d132a80af4caec8084bd642e59ca6395f6..153f1e49fcc0a572dd5463e38c9cc4bc572c9332 100644 (file)
@@ -73,7 +73,7 @@ function userCan($permission, Ownable $ownable = null)
  */
 function setting($key = null, $default = false)
 {
-    $settingService = app(\BookStack\Services\SettingService::class);
+    $settingService = resolve(\BookStack\Services\SettingService::class);
     if (is_null($key)) return $settingService;
     return $settingService->get($key, $default);
 }
@@ -126,6 +126,16 @@ function redirect($to = null, $status = 302, $headers = [], $secure = null)
     return app('redirect')->to($to, $status, $headers, $secure);
 }
 
+function icon($name, $attrs = []) {
+    $iconPath = resource_path('assets/icons/' . $name . '.svg');
+    $attrString = ' ';
+    foreach ($attrs as $attrName => $attr) {
+        $attrString .=  $attrName . '="' . $attr . '" ';
+    }
+    $fileContents = file_get_contents($iconPath);
+    return  str_replace('<svg', '<svg' . $attrString, $fileContents);
+}
+
 /**
  * Generate a url with multiple parameters for sorting purposes.
  * Works out the logic to set the correct sorting direction
@@ -156,4 +166,4 @@ function sortUrl($path, $data, $overrideData = [])
     if (count($queryStringSections) === 0) return $path;
 
     return baseUrl($path . '?' . implode('&', $queryStringSections));
-}
+}
\ No newline at end of file