Application.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/7/6
  6. * Time: 下午3:30
  7. */
  8. namespace app\framework\Foundation;
  9. use app\framework\Events\EventServiceProvider;
  10. use Illuminate\Log\LogServiceProvider;
  11. use Illuminate\Routing\RoutingServiceProvider;
  12. class Application extends \Illuminate\Foundation\Application
  13. {
  14. public $makingRouteList;
  15. private $configurationIsCached;
  16. private $timer = LARAVEL_START;
  17. public function getTime()
  18. {
  19. $result = microtime(true) - $this->timer;
  20. $this->timer = microtime(true);
  21. return $result;
  22. }
  23. protected function registerBaseServiceProviders()
  24. {
  25. $this->register(new EventServiceProvider($this));
  26. $this->register(new RoutingServiceProvider($this));
  27. $this->register(new LogServiceProvider($this));
  28. }
  29. /**
  30. * @param null $file
  31. * @return string
  32. */
  33. public function getRoutesPath($file = null)
  34. {
  35. $file = !empty($file) ? DIRECTORY_SEPARATOR . $file : '';
  36. return $this->basePath() . DIRECTORY_SEPARATOR . 'routes' . $file;
  37. }
  38. public function getRoutesDataPath($file = null)
  39. {
  40. $file = !empty($file) ? DIRECTORY_SEPARATOR . $file : '';
  41. return $this->basePath() . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'data' . $file;
  42. }
  43. public function getUrlRoutesPath($file = null)
  44. {
  45. $file = !empty($file) ? DIRECTORY_SEPARATOR . $file : '';
  46. return $this->basePath() . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'urlRoutes' . $file;
  47. }
  48. public function getFrontendPath()
  49. {
  50. return $this->path() . DIRECTORY_SEPARATOR . 'frontend';
  51. }
  52. public function getBackendPath()
  53. {
  54. return $this->path() . DIRECTORY_SEPARATOR . 'backend';
  55. }
  56. public function getPluginsPath()
  57. {
  58. return $this->basePath() . DIRECTORY_SEPARATOR . 'plugins';
  59. }
  60. public function getPaymentPath()
  61. {
  62. return $this->path() . DIRECTORY_SEPARATOR . 'payment';
  63. }
  64. public function makingRouteList()
  65. {
  66. // todo 暂时解决
  67. return (bool)$this->makingRouteList;
  68. }
  69. /**
  70. * @return bool
  71. */
  72. public function configurationIsCached()
  73. {
  74. if (!isset($this->configurationIsCached)) {
  75. $this->configurationIsCached = parent::configurationIsCached();
  76. }
  77. return $this->configurationIsCached;
  78. }
  79. }