ShopOutsideRoute.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2022/1/5
  8. * Time: 14:05
  9. */
  10. namespace app\common\route;
  11. use app\common\exceptions\AppException;
  12. use Illuminate\Support\Str;
  13. class ShopOutsideRoute extends AbstractShopRoute
  14. {
  15. public $namespace = 'app\\outside';
  16. // protected $middleware = [BasicInformation::class];
  17. public function __construct($path)
  18. {
  19. parent::__construct($path);
  20. }
  21. public function shopMatch($routes, $first)
  22. {
  23. $namespace = $this->namespace;
  24. $class_name = '';
  25. $action = '';
  26. if (class_exists($namespace.'\\controllers\\'.ucfirst(Str::camel($first)).'Controller')) {
  27. $class_name = $namespace.'\\controllers\\'.ucfirst(Str::camel($first)).'Controller';
  28. $action = array_shift($routes);
  29. } else {
  30. $namespace .= '\\modules\\'.$first;
  31. $namespace_module = $namespace;
  32. foreach ($routes as $route) {
  33. if ($class_name) {
  34. $action = $route;
  35. break;
  36. }
  37. $controller = ucfirst(Str::camel($route)).'Controller';
  38. if (class_exists($namespace.'\\controllers\\'.$controller)) {
  39. $class_name = $namespace.'\\controllers\\'.$controller;
  40. } elseif (class_exists($namespace_module.'\\controllers\\'.$controller)) {
  41. $class_name = $namespace_module.'\\controllers\\'.$controller;
  42. } else {
  43. $namespace .= '\\'.$route;
  44. $namespace_module .= '\\modules\\'.$route;
  45. }
  46. }
  47. }
  48. return [$class_name,$action];
  49. }
  50. }