Browse Source

adding #4

develop v0.3.0
Björn 4 years ago
parent
commit
268d6a01b4
2 changed files with 31 additions and 1 deletions
  1. +1
    -1
      composer.json
  2. +30
    -0
      src/Functions.php

+ 1
- 1
composer.json View File

@ -1,6 +1,6 @@
{
"name": "tentakelfabrik/super-gear-directus",
"version": "0.2.2",
"version": "0.3.0",
"type": "library",
"license": "MIT",
"authors": [


+ 30
- 0
src/Functions.php View File

@ -10,3 +10,33 @@ function app($class)
{
return new $class();
}
/**
* function similar to blade asset
*
* @param $path
* @return string
*
*/
function asset($path, $prefix = '/public')
{
// get flight
$app = Flight::app();
// getting basePath
$basePath = $app->get('basePath');
// path to mix-manifest
$file = $app->get('basePath').'mix-manifest.json';
if (file_exists($file)) {
$manifest = file_get_contents($file);
$files = json_decode($manifest, true);
if (isset($files[$prefix.$path])) {
$path = str_replace($prefix, '', $files[$prefix.$path]);
}
}
return $path;
}

Loading…
Cancel
Save