Skip to content

Commit

Permalink
Merge pull request #6881 from ChurchCRM/6880-bug-initial-setup-does-n…
Browse files Browse the repository at this point in the history
…ot-work-if-churchcrm-not-at-root-of-website

Handle adjusting BasePath, utilizing discovered rootPath
  • Loading branch information
DAcodedBEAT authored Feb 19, 2024
2 parents b090a4a + a361b69 commit 1d39439
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/api/index.php', '', $_SERVER['SCRIPT_NAME']);
use ChurchCRM\Slim\Middleware\AuthMiddleware;
use ChurchCRM\Slim\Middleware\VersionMiddleware;
use Slim\Factory\AppFactory;
Expand All @@ -14,7 +15,7 @@
$container->compile();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/api');
$app->setBasePath($rootPath . '/api');

$app->add(VersionMiddleware::class);
$app->add(AuthMiddleware::class);
Expand Down
3 changes: 2 additions & 1 deletion src/external/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
// This file is generated by Composer
require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/external/index.php', '', $_SERVER['SCRIPT_NAME']);
$container = new ContainerBuilder();
$container->compile();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/external');
$app->setBasePath($rootPath . '/external');

$app->add(VersionMiddleware::class);
$app->addRoutingMiddleware();
Expand Down
3 changes: 2 additions & 1 deletion src/kiosk/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// This file is generated by Composer
require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/kiosk/index.php', '', $_SERVER['SCRIPT_NAME']);
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\model\ChurchCRM\KioskDevice;
use ChurchCRM\model\ChurchCRM\KioskDeviceQuery;
Expand All @@ -14,7 +15,7 @@
$container = new ContainerBuilder();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/kiosk');
$app->setBasePath($rootPath . '/kiosk');

if (SystemConfig::debugEnabled()) {
$app->addErrorMiddleware(true, true, true);
Expand Down
3 changes: 2 additions & 1 deletion src/session/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/session/index.php', '', $_SERVER['SCRIPT_NAME']);
$container = new ContainerBuilder();
$container->compile();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/session');
$app->setBasePath($rootPath . '/session');


require __DIR__ . '/../Include/slim/error-handler.php';
Expand Down
4 changes: 2 additions & 2 deletions src/setup/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
}

require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/setup/index.php', '', $_SERVER['SCRIPT_NAME']);

SystemURLs::init($rootPath, '', __DIR__ . '/../');
SystemConfig::init();

$container = new ContainerBuilder();
$container->compile();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/setup');
$app->setBasePath($rootPath . '/setup');

require __DIR__ . '/../Include/slim/error-handler.php';

Expand Down
3 changes: 2 additions & 1 deletion src/v2/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require_once __DIR__ . '/../vendor/autoload.php';

$rootPath = str_replace('/v2/index.php', '', $_SERVER['SCRIPT_NAME']);
use ChurchCRM\Slim\Middleware\AuthMiddleware;
use ChurchCRM\Slim\Middleware\VersionMiddleware;
use Slim\Factory\AppFactory;
Expand All @@ -13,7 +14,7 @@
$container = new ContainerBuilder();
AppFactory::setContainer($container);
$app = AppFactory::create();
$app->setBasePath('/v2');
$app->setBasePath($rootPath . '/v2');

$app->add(VersionMiddleware::class);
$app->add(AuthMiddleware::class);
Expand Down

0 comments on commit 1d39439

Please sign in to comment.