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

Merged
merged 1 commit into from
Jan 18, 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/ContentReviewCMSExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\LeftAndMainExtension;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ContentReview\Forms\ReviewContentHandler;
use SilverStripe\ContentReview\Traits\PermissionChecker;
Expand All @@ -17,6 +18,8 @@
/**
* CMSPageEditController extension to receive the additional action button from
* SiteTreeContentReview::updateCMSActions()
*
* @extends LeftAndMainExtension<CMSMain>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @extends LeftAndMainExtension<CMSMain>
* @extends LeftAndMainExtension<CMSPageEditController|ContentReviewCMSExtension>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in person, both CMSPageEditController and CMSPageSettingsController which this is applied to are subclasses of CMSMain, so it makes sense to use that superclass as the typehint here.

*/
class ContentReviewCMSExtension extends LeftAndMainExtension
{
Expand Down
9 changes: 6 additions & 3 deletions src/Extensions/ContentReviewDefaultSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\SiteConfig\SiteConfig;

/**
* This extensions add a default schema for new pages and pages without a content
Expand All @@ -22,6 +23,8 @@
* @property int $ReviewPeriodDays
* @method SilverStripe\ORM\ManyManyList<Group> ContentReviewGroups()
* @method SilverStripe\ORM\ManyManyList<Member> ContentReviewUsers()
*
* @extends DataExtension<SiteConfig>
*/
class ContentReviewDefaultSettings extends DataExtension
{
Expand Down Expand Up @@ -88,15 +91,15 @@ public function getOwnerNames()
}

/**
* @return ManyManyList
* @return ManyManyList<Group>
*/
public function OwnerGroups()
{
return $this->owner->getManyManyComponents('ContentReviewGroups');
}

/**
* @return ManyManyList
* @return ManyManyList<Member>
*/
public function OwnerUsers()
{
Expand Down Expand Up @@ -180,7 +183,7 @@ public function updateCMSFields(FieldList $fields)
* Get all Members that are default Content Owners. This includes checking group hierarchy
* and adding any direct users.
*
* @return ArrayList
* @return ArrayList<Group|Member>
*/
public function ContentReviewOwners()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/ContentReviewLeftAndMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace SilverStripe\ContentReview\Extensions;

use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\LeftAndMainExtension;

/**
* @extends LeftAndMainExtension<LeftAndMain>
*/
class ContentReviewLeftAndMainExtension extends LeftAndMainExtension
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/ContentReviewOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;

/**
* @method SilverStripe\ORM\ManyManyList<SiteTree> SiteTreeContentReview()
*
* @extends DataExtension<Group|Member>
*/
class ContentReviewOwner extends DataExtension
{
Expand Down
10 changes: 6 additions & 4 deletions src/Extensions/SiteTreeContentReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
* @method SilverStripe\ORM\ManyManyList<Group> ContentReviewGroups()
* @method SilverStripe\ORM\ManyManyList<Member> ContentReviewUsers()
* @method SilverStripe\ORM\HasManyList<ContentReviewLog> ReviewLogs()
*
* @extends DataExtension<SiteTree>
*/
class SiteTreeContentReview extends DataExtension implements PermissionProvider
{
Expand Down Expand Up @@ -119,7 +121,7 @@ public static function get_schedule()
* @param SS_List $groups
* @param SS_List $members
*
* @return ArrayList
* @return ArrayList<Group|Member>
*/
public static function merge_owners(SS_List $groups, SS_List $members)
{
Expand Down Expand Up @@ -293,7 +295,7 @@ public function getEditorName()
* Get all Members that are Content Owners to this page. This includes checking group
* hierarchy and adding any direct users.
*
* @return ArrayList
* @return ArrayList<Group|Member>
*/
public function ContentReviewOwners()
{
Expand All @@ -304,15 +306,15 @@ public function ContentReviewOwners()
}

/**
* @return ManyManyList
* @return ManyManyList<Group>
*/
public function OwnerGroups()
{
return $this->owner->getManyManyComponents("ContentReviewGroups");
}

/**
* @return ManyManyList
* @return ManyManyList<Member>
*/
public function OwnerUsers()
{
Expand Down