Skip to content

Commit

Permalink
ENH Add generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 12, 2024
1 parent 67e0e1c commit 3e3a795
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/ErrorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public function canAddChildren($member = null)
public static function response_for($statusCode, $errorMessage = null)
{
// first attempt to dynamically generate the error page
/** @var ErrorPage $errorPage */
$errorPage = ErrorPage::get()
->filter([
"ErrorCode" => $statusCode
Expand Down Expand Up @@ -185,7 +184,6 @@ protected function requireDefaultRecordFixture($defaultData)
{
$code = $defaultData['ErrorCode'];

/** @var ErrorPage $page */
$page = ErrorPage::get()->find('ErrorCode', $code);
if (!$page) {
$page = static::create();
Expand Down
3 changes: 2 additions & 1 deletion src/ErrorPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Controller for ErrorPages.
*
* @extends PageController<ErrorPage>
*/
class ErrorPageController extends PageController
{
Expand All @@ -30,7 +32,6 @@ protected function init()
*/
public function handleRequest(HTTPRequest $request): HTTPResponse
{
/** @var ErrorPage $page */
$page = $this->data();
$response = parent::handleRequest($request);
$response->setStatusCode($page->ErrorCode);
Expand Down
4 changes: 3 additions & 1 deletion src/ErrorPageControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\Form;

/**
* Enhances error handling for a controller with ErrorPage generated output
*
* @extends Extension<Controller|Form>
*/
class ErrorPageControllerExtension extends Extension
{

/**
* Used by {@see RequestHandler::httpError}
*
Expand Down
4 changes: 3 additions & 1 deletion src/ErrorPageFileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

namespace SilverStripe\ErrorPage;

use SilverStripe\Assets\Shortcodes\FileShortcodeProvider;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;

/**
* Decorates {@see File} with ErrorPage support
*
* @extends DataExtension<FileShortcodeProvider>
*/
class ErrorPageFileExtension extends DataExtension
{

/**
* Used by {@see File::handle_shortcode}
*
Expand Down

0 comments on commit 3e3a795

Please sign in to comment.