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 #336

Merged
merged 1 commit into from
Jan 23, 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
3 changes: 3 additions & 0 deletions src/Extensions/CustomSiteConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\SiteConfig\SiteConfig;

/**
* Adds new global settings.
*
* @extends DataExtension<SiteConfig>
*/
class CustomSiteConfig extends DataExtension
{
Expand Down
3 changes: 2 additions & 1 deletion src/Extensions/CwpCommentingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace CWP\CWP\Extensions;

use SilverStripe\Comments\Controllers\CommentingController;
use SilverStripe\Control\Email\Email;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\Form;

/**
* Customises the comment form to conform to government usability standards
*
* {@see CommentingController}
* @extends Extension<CommentingController>
*/
class CwpCommentingExtension extends Extension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/CwpSiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

namespace CWP\CWP\Extensions;

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\DataExtension;

/**
* @extends DataExtension<SiteTree>
*/
class CwpSiteTreeExtension extends DataExtension
{
private static $db = array(
Expand Down
5 changes: 4 additions & 1 deletion src/Extensions/CwpSiteTreeFileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

namespace CWP\CWP\Extensions;

use SilverStripe\Assets\File;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\View\Requirements;

/**
* @extends DataExtension<File>
*/
class CwpSiteTreeFileExtension extends DataExtension
{

public function updateCMSFields(FieldList $fields)
{
Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css');
Expand Down
2 changes: 2 additions & 0 deletions src/Extensions/CwpWorkflowDefinitionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Ensures that the default template is created
*
* @extends DataExtension<WorkflowDefinition>
*/
class CwpWorkflowDefinitionExtension extends DataExtension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/MaintenanceProxyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
namespace CWP\CWP\Extension;

use BringYourOwnIdeas\Maintenance\Reports\SiteSummary;
use BringYourOwnIdeas\Maintenance\Util\ApiLoader;
use BringYourOwnIdeas\Maintenance\Util\ComposerLoader;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Extension;

/**
* Used to configure proxy settings for bringyourownideas/silverstripe-maintenance and its related modules
*
* @see https://www.cwp.govt.nz/developer-docs/en/2/how_tos/external_http_requests_with_proxy
*
* @extends Extension<ComposerLoader|ApiLoader>
*/
class MaintenanceProxyExtension extends Extension
{
Expand Down
5 changes: 4 additions & 1 deletion src/Extensions/TaxonomyTermExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
use SilverStripe\Taxonomy\TaxonomyTerm;

/**
* @extends DataExtension<TaxonomyTerm>
*/
class TaxonomyTermExtension extends DataExtension
{

private static $api_access = true;

private static $belongs_many_many = array(
Expand Down
4 changes: 4 additions & 0 deletions src/PageTypes/BaseHomePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use PageController;

/**
* @template T of BaseHomePage
* @extends PageController<T>
*/
class BaseHomePageController extends PageController
{
public function getNewsPage()
Expand Down
4 changes: 4 additions & 0 deletions src/PageTypes/BasePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\ORM\FieldType\DBDatetime;

/**
* @template T of BasePage
* @extends ContentController<T>
*/
class BasePageController extends ContentController
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/PageTypes/DatedUpdateHolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*
* When the user clicks on a month, pagination will be reset, but tags retained. Pagination retains all other
* parameters.
*
* @template T of DatedUpdateHolder
* @extends PageController<T>
*/
class DatedUpdateHolderController extends PageController
{
Expand Down
2 changes: 2 additions & 0 deletions src/PageTypes/EventHolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
* When the user clicks on a month, pagination will be reset, but tags retained. Pagination retains all other
* parameters.
*
* @extends DatedUpdateHolderController<EventHolder>
*/
class EventHolderController extends DatedUpdateHolderController
{
Expand Down
3 changes: 3 additions & 0 deletions src/PageTypes/EventPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use PageController;

/**
* @extends PageController<EventPage>
*/
class EventPageController extends PageController
{

Expand Down
3 changes: 3 additions & 0 deletions src/PageTypes/NewsHolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use CWP\Core\Feed\CwpAtomFeed;
use SilverStripe\Control\RSS\RSSFeed;

/**
* @extends DatedUpdateHolderController<NewsHolder>
*/
class NewsHolderController extends DatedUpdateHolderController
{
private static $allowed_actions = [
Expand Down
3 changes: 3 additions & 0 deletions src/PageTypes/SitemapPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use PageController;
use SilverStripe\CMS\Model\SiteTree;

/**
* @extends PageController<SitemapPage>
*/
class SitemapPageController extends PageController
{
private static $allowed_actions = [
Expand Down