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.

92 lines
3.5 KiB

  1. <?php
  2. $params = array_merge(
  3. require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
  4. );
  5. return [
  6. 'id' => 'api',
  7. 'basePath' => dirname(__DIR__),
  8. 'controllerNamespace' => 'api\controllers',
  9. 'bootstrap' => ['log'],
  10. 'modules' => [],
  11. 'components' => [
  12. 'cart' => ['class' => 'api\logic\CartLogic'],
  13. 'comment' => ['class' => 'api\logic\CommentLogic'],
  14. 'order' => ['class' => 'api\logic\OrderLogic'],
  15. 'visitor' => ['class' => 'api\logic\UserLogic'],
  16. 'address' => ['class' => 'api\logic\AddressLogic'],
  17. 'collection' => ['class' => 'api\logic\CollectionLogic'],
  18. 'request' => [
  19. 'parsers' => [
  20. 'application/json' => 'yii\web\JsonParser',
  21. ],
  22. 'csrfParam' => '_csrf-api',
  23. ],
  24. 'session' => [
  25. // this is the name of the session cookie used for login on the app
  26. 'name' => 'api',
  27. ],
  28. 'log' => [
  29. 'traceLevel' => YII_DEBUG ? 3 : 0,
  30. 'targets' => [
  31. [
  32. 'class' => 'yii\log\FileTarget',
  33. 'levels' => ['error', 'warning'],
  34. ],
  35. ],
  36. ],
  37. 'user' => [
  38. 'identityClass' => 'common\models\User',
  39. 'enableAutoLogin' => true,
  40. 'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
  41. ],
  42. 'errorHandler' => [
  43. 'errorAction' => 'site/error',
  44. ],
  45. 'urlManager' => [
  46. 'enablePrettyUrl' => true,
  47. 'enableStrictParsing' => true,
  48. 'showScriptName' => false,
  49. 'rules' => [
  50. ['class' => 'yii\rest\UrlRule', 'controller' => 'goods', 'pluralize' => false],
  51. ['class' => 'yii\rest\UrlRule', 'controller' => 'address', 'pluralize' => false],
  52. ['class' => 'yii\rest\UrlRule', 'controller' => 'taking-site'],
  53. ['class' => 'yii\rest\UrlRule', 'controller' => 'cart'],
  54. ['class' => 'yii\rest\UrlRule', 'controller' => 'comment',
  55. 'extraPatterns' => [
  56. 'DELETE ' => 'delete'
  57. ]],
  58. ['class' => 'yii\rest\UrlRule', 'controller' => 'order'],
  59. ['class' => 'yii\rest\UrlRule', 'controller' => 'collection',
  60. 'extraPatterns' => [
  61. 'DELETE ' => 'delete'
  62. ]
  63. ],
  64. ['class' => 'yii\rest\UrlRule',
  65. 'controller' => 'user',
  66. 'pluralize' => false,
  67. 'extraPatterns' => [
  68. 'GET token' => 'token'
  69. ]
  70. ],
  71. [
  72. 'class' => 'yii\rest\UrlRule',
  73. 'controller' => 'admin',
  74. 'extraPatterns' => [
  75. 'GET menu' => 'menu',
  76. 'GET create' => 'create'
  77. ]
  78. ],
  79. [
  80. 'class' => 'yii\rest\UrlRule',
  81. 'controller' => 'site',
  82. 'extraPatterns' => [
  83. 'GET index' => 'index',
  84. ]
  85. ],
  86. ],
  87. ],
  88. ],
  89. 'params' => $params,
  90. ];