Skip to content

Commit

Permalink
add: Stubs for Page and PageController to ensure these symbols also e…
Browse files Browse the repository at this point in the history
…xist for modules (syntro-opensource#18)
  • Loading branch information
erikfrerejean authored Apr 29, 2023
1 parent 0222b18 commit ee32fa8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
exit(1);
}

// Ensure that the `Page` and `PageController` classes exist, if they don't _(for example when testing a
// silverstripe module)_ ensure that the symbols are registered.
if (!class_exists(\Page::class)) {
require __DIR__ . '/stubs/Page.php';
}

if (!class_exists(\PageController::class)) {
require __DIR__ . '/stubs/PageController.php';
}

// Ensure global $_SERVER exists
global $_SERVER;
if (!$_SERVER) {
Expand Down
8 changes: 8 additions & 0 deletions stubs/Page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace {

use SilverStripe\CMS\Model\SiteTree;

class Page extends SiteTree {}
}
8 changes: 8 additions & 0 deletions stubs/PageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace {

use SilverStripe\CMS\Controllers\ContentController;

class PageController extends ContentController {}
}

0 comments on commit ee32fa8

Please sign in to comment.