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

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
6 changes: 2 additions & 4 deletions src/AddToCampaignHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct($controller = null, $data = [], $name = 'AddToCampai
/**
* Get what ChangeSets are available for an item to be added to by this user
*
* @return ArrayList|ChangeSet[]
* @return ArrayList<ChangeSet>
*/
protected function getAvailableChangeSets()
{
Expand All @@ -111,7 +111,7 @@ protected function getAvailableChangeSets()
* Get changesets that a given object is already in
*
* @param DataObject
* @return ArrayList[ChangeSet]
* @return ArrayList<ChangeSet>
*/
protected function getInChangeSets($object)
{
Expand Down Expand Up @@ -272,8 +272,6 @@ public function addToCampaign($object, $data): HTTPResponse
{
// Extract $campaignID from $data
$campaignID = $this->getOrCreateCampaign($data);

/** @var ChangeSet $changeSet */
$changeSet = ChangeSet::get()->byID($campaignID);

if (!$changeSet) {
Expand Down
8 changes: 1 addition & 7 deletions src/CampaignAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ protected function getListResource()
],
'_embedded' => [$treeClass => []]
];
/** @var ChangeSet $item */
foreach ($items as $item) {
$sync = $this->shouldCampaignSync($item);
$resource = $this->getChangeSetResource($item, $sync);
Expand Down Expand Up @@ -304,7 +303,6 @@ protected function getChangeSetResource(ChangeSet $changeSet, $sync = false)
continue;
}

/** @var ChangesetItem $changeSetItem */
$resource = $this->getChangeSetItemResource($changeSetItem);
if (!empty($resource)) {
$hal['_embedded']['items'][] = $resource;
Expand Down Expand Up @@ -406,7 +404,7 @@ protected function getChangeSetItemResource(ChangeSetItem $changeSetItem)
/**
* Gets viewable list of campaigns
*
* @return SS_List
* @return SS_List<ChangeSet>
*/
protected function getListItems()
{
Expand Down Expand Up @@ -446,7 +444,6 @@ public function readCampaign(HTTPRequest $request)
return (new HTTPResponse(null, 400));
}

/** @var ChangeSet $changeSet */
$changeSet = ChangeSet::get()->filter('IsInferred', 0)->byID($request->param('ID'));

if (!$changeSet) {
Expand Down Expand Up @@ -489,9 +486,7 @@ public function removeCampaignItem(HTTPRequest $request)
return (new HTTPResponse(null, 400));
}

/** @var ChangeSet $campaign */
$campaign = ChangeSet::get()->byID($campaignID);
/** @var ChangeSetItem $item */
$item = ChangeSetItem::get()->byID($itemID);
if (!$campaign || !$item) {
return (new HTTPResponse(null, 404));
Expand Down Expand Up @@ -558,7 +553,6 @@ public function publishCampaign(HTTPRequest $request)
return (new HTTPResponse(null, 400));
}

/** @var ChangeSet $changeSet */
$changeSet = ChangeSet::get()->byID($id);
if (!$changeSet) {
return (new HTTPResponse(null, 404));
Expand Down
4 changes: 4 additions & 0 deletions src/CampaignAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

namespace SilverStripe\CampaignAdmin;

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

/**
* @extends Extension<LeftAndMain>
*/
class CampaignAdminExtension extends Extension
{
public function init()
Expand Down
3 changes: 3 additions & 0 deletions src/SiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace SilverStripe\CampaignAdmin;

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Tab;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Permission;

/**
* Handles adding the "Add to Campaign" button to a page's secondary actions menu
*
* @extends DataExtension<SiteTree>
*/
class SiteTreeExtension extends DataExtension
{
Expand Down