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 10, 2024
1 parent f616c77 commit 4394b7e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions code/AdminErrorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Extension;

/**
* @extends Extension<RequestHandler>
*/
class AdminErrorExtension extends Extension
{
/**
Expand Down
6 changes: 5 additions & 1 deletion code/CMSEditLinkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*
* If the cms_edit_owner is a has_one relation, the class on the other end
* of the relation must have a CMSEditLink() method.
*
* @template T of LeftAndMain|DataObject
* @extends Extension<T&static>
*/
class CMSEditLinkExtension extends Extension
{
Expand All @@ -40,7 +43,7 @@ class CMSEditLinkExtension extends Extension
/**
* Get the ModelAdmin, LeftAndMain, or DataObject which owns this object for CMS editing purposes.
*
* @return LeftAndMain|DataObject|null
* @return DataObject|LeftAndMain|null
*/
public function getCMSEditOwner()
{
Expand Down Expand Up @@ -71,6 +74,7 @@ public function getCMSEditLinkForManagedDataObject(DataObject $obj, string $reci
*/
public function CMSEditLink(): string
{
/** @var DataObject|LeftAndMain|null $owner */
$owner = $this->owner->getCMSEditOwner();
if (!$owner || !$owner->exists()) {
return '';
Expand Down
4 changes: 4 additions & 0 deletions code/Forms/GridFieldDetailFormPreviewExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
use SilverStripe\Admin\Navigator\SilverStripeNavigator;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\View\SSViewer;

/**
* @extends Extension<GridFieldDetailForm_ItemRequest>
*/
class GridFieldDetailFormPreviewExtension extends Extension
{
public function updateItemEditForm(Form $form): void
Expand Down
4 changes: 4 additions & 0 deletions code/Forms/GridFieldPrintButtonExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
namespace SilverStripe\Admin\Forms;

use SilverStripe\Core\Extension;
use SilverStripe\Forms\GridField\GridFieldPrintButton;
use SilverStripe\View\Requirements;

/**
* @extends Extension<GridFieldPrintButton>
*/
class GridFieldPrintButtonExtension extends Extension
{
public function updatePrintData($data)
Expand Down
3 changes: 3 additions & 0 deletions code/LeftAndMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

/**
* Plug-ins for additional functionality in your LeftAndMain classes.
*
* @template T of LeftAndMain
* @extends Extension<T>
*/
abstract class LeftAndMainExtension extends Extension
{
Expand Down

0 comments on commit 4394b7e

Please sign in to comment.