Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #95

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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