loader.php 978 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * This function is registered on the auto-loader stack by the front controller.
  4. */
  5. return function($class) {
  6. // ----------------------------------------------------------
  7. // Replace namespace slashes with directory slashes.
  8. // ----------------------------------------------------------
  9. $file = System\Str::lower(str_replace('\\', '/', $class));
  10. // ----------------------------------------------------------
  11. // Should the class be aliased?
  12. // ----------------------------------------------------------
  13. if (array_key_exists($class, $aliases = System\Config::get('application.aliases')))
  14. {
  15. return class_alias($aliases[$class], $class);
  16. }
  17. if (file_exists($path = BASE_PATH.$file.EXT))
  18. {
  19. require $path;
  20. }
  21. elseif (file_exists($path = APP_PATH.'models/'.$file.EXT))
  22. {
  23. require $path;
  24. }
  25. elseif (file_exists($path = APP_PATH.'packages/'.$file.EXT))
  26. {
  27. require $path;
  28. }
  29. elseif (file_exists($path = APP_PATH.$file.EXT))
  30. {
  31. require $path;
  32. }
  33. };