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 11, 2024
1 parent d13eec6 commit f722f2b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/Extensions/ElementalAreaUsedOnTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
use SilverStripe\ORM\ValidationException;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Admin\Forms\UsedOnTable;

/**
* @extends DataExtension<UsedOnTable>
*/
class ElementalAreaUsedOnTableExtension extends DataExtension
{

/**
* Hides ElementalArea's from the "Used On" tab when viewing files
*
Expand Down Expand Up @@ -56,7 +59,6 @@ public function updateUsageAncestorDataObjects(array &$ancestorDataObjects, Data
try {
// BaseElement::getPage() caches results so there's no performance decrease from
// also calling it in updateUsageExcludeDataObject()
/** @var SiteTree $page */
if ($page = $dataObject->getPage()) {
$ancestorDataObjects[] = $page;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Extensions/ElementalAreasExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
* 'ElementalArea2'
* );
*
* @package elemental
* @template T of DataObject
* @extends DataExtension<T&static>
*/
class ElementalAreasExtension extends DataExtension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/ElementalCMSMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

namespace DNADesign\Elemental\Extensions;

use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\Form;

/**
* @extends Extension<CMSMain>
*/
class ElementalCMSMainExtension extends Extension
{
/**
Expand Down
5 changes: 4 additions & 1 deletion src/Extensions/ElementalContentControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
use SilverStripe\ORM\DataObject;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Extensions\ElementalAreasExtension;
use SilverStripe\CMS\Controllers\ContentController;

/**
* @extends Extension<ContentController>
*/
class ElementalContentControllerExtension extends Extension
{
/**
Expand All @@ -25,7 +29,6 @@ public function handleElement()
return false;
}

/** @var DataObject $elementOwner */
$elementOwner = $this->owner->data();

if (!$elementOwner->hasExtension(ElementalAreasExtension::class)) {
Expand Down
5 changes: 4 additions & 1 deletion src/Extensions/ElementalLeftAndMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace DNADesign\Elemental\Extensions;

use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Core\Extension;
use SilverStripe\View\Requirements;

/**
* @extends Extension<LeftAndMain>
*/
class ElementalLeftAndMainExtension extends Extension
{

public function init()
{
Requirements::add_i18n_javascript('dnadesign/silverstripe-elemental:client/lang');
Expand Down
2 changes: 2 additions & 0 deletions src/Extensions/ElementalPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/**
* @property int ElementalAreaID
* @method ElementalArea ElementalArea()
*
* @extends ElementalAreasExtension<SiteTree>
*/
class ElementalPageExtension extends ElementalAreasExtension
{
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use SilverStripe\Core\Extension;
use SilverStripe\Forms\Form;
use DNADesign\Elemental\Models\BaseElement;
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClassHandler;

/**
* Class GridFieldAddNewMultiClassHandlerExtension
* @package DNADesign\Elemental\Extensions
* @extends Extension<GridFieldAddNewMultiClassHandler>
*/
class GridFieldAddNewMultiClassHandlerExtension extends Extension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/GridFieldDetailFormItemRequestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
use SilverStripe\ORM\FieldType\DBField;

/**
* @extends Extension<GridFieldDetailForm_ItemRequest>
*/
class GridFieldDetailFormItemRequestExtension extends Extension
{
public function updateBreadcrumbs($crumbs)
Expand Down
5 changes: 3 additions & 2 deletions src/Models/ElementalArea.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\Models;

use DNADesign\Elemental\Controllers\ElementController;
use DNADesign\Elemental\Extensions\ElementalAreasExtension;
use DNADesign\Elemental\TopPage\DataExtension;
use SilverStripe\Core\ClassInfo;
Expand Down Expand Up @@ -124,7 +125,7 @@ public function setOwnerPageCached(DataObject $page)

/**
* A cache-aware accessor for the elements
* @return ArrayList|HasManyList|BaseElement[]
* @return HasManyList<BaseElement>
*/
public function Elements()
{
Expand Down Expand Up @@ -160,7 +161,7 @@ public function Breadcrumbs()
* its' controller, making it easier to access and process form logic and
* actions stored in {@link ElementController}.
*
* @return ArrayList
* @return ArrayList<ElementController>
* @throws \Exception
*/
public function ElementControllers()
Expand Down

0 comments on commit f722f2b

Please sign in to comment.