extensions_web.php 829 B

12345678910111213141516171819202122
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. Route::group(['prefix' => 'extensions'], function () {
  4. // get all extensions that are inside App/Extensions
  5. // It is important that the extensions are inside a folder with the name of the extension
  6. // while those folders are inside Folders with the name of the type of extension like PaymentGateways, Themes, etc.
  7. $extensionNamespaces = glob(app_path() . '/Extensions/*', GLOB_ONLYDIR);
  8. $extensions = [];
  9. foreach ($extensionNamespaces as $extensionNamespace) {
  10. $extensions = array_merge($extensions, glob($extensionNamespace . '/*', GLOB_ONLYDIR));
  11. }
  12. foreach ($extensions as $extension) {
  13. $routesFile = $extension . '/web_routes.php';
  14. if (file_exists($routesFile)) {
  15. include_once $routesFile;
  16. }
  17. }
  18. });