You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
748 B

3 years ago
  1. <?php
  2. /**
  3. * fake function for blade @inject
  4. *
  5. * @param string $class
  6. * @return object
  7. */
  8. function app($class)
  9. {
  10. return new $class();
  11. }
  12. /**
  13. * function similar to blade asset
  14. *
  15. * @param $path
  16. * @return string
  17. *
  18. */
  19. function asset($path, $prefix = '/public')
  20. {
  21. // get flight
  22. $app = Flight::app();
  23. // getting basePath
  24. $basePath = $app->get('basePath');
  25. // path to mix-manifest
  26. $file = $app->get('basePath').'mix-manifest.json';
  27. if (file_exists($file)) {
  28. $manifest = file_get_contents($file);
  29. $files = json_decode($manifest, true);
  30. if (isset($files[$prefix.$path])) {
  31. $path = str_replace($prefix, '', $files[$prefix.$path]);
  32. }
  33. }
  34. return $path;
  35. }