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 23, 2024
1 parent a12a4f2 commit 1a35e0f
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/Actions/AssignUsersToWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
Expand All @@ -20,6 +21,9 @@
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
* @subpackage actions
*
* @method ManyManyList<Member> Users()
* @method ManyManyList<Group> Groups()
*/
class AssignUsersToWorkflowAction extends WorkflowAction
{
Expand Down Expand Up @@ -87,7 +91,7 @@ public function fieldLabels($relations = true)
/**
* Returns a set of all Members that are assigned to this WorkflowAction subclass, either directly or via a group.
*
* @return ArrayList
* @return ArrayList<Member>
*/
public function getAssignedMembers()
{
Expand Down
9 changes: 6 additions & 3 deletions src/Admin/AdvancedWorkflowAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
use SilverStripe\Forms\GridField\GridFieldImportButton;
use SilverStripe\Forms\GridField\GridFieldPaginator;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\View\Requirements;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowDefinition;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use Symbiote\AdvancedWorkflow\Dev\WorkflowBulkLoader;
use Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldExportAction;
use Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldWorkflowRestrictedEditButton;
Expand Down Expand Up @@ -195,7 +197,7 @@ public function getEditForm($id = null, $fields = null)
}

$this->extend('updateEditFormAfter', $form);

return $form;
}

Expand Down Expand Up @@ -260,7 +262,7 @@ public function setFieldFormatting(&$config)
*
* @param Member $member
* @param string $fieldName The name of the gridfield that determines which dataset to return
* @return DataList
* @return ArrayList<WorkflowInstance>
* @todo Add the ability to see embargo/expiry dates in report-gridfields at-a-glance if QueuedJobs module installed
*/
public function userObjects(Member $user, $fieldName)
Expand Down Expand Up @@ -293,11 +295,12 @@ public function userObjects(Member $user, $fieldName)
return $list;
}

/*
/**
* Return content-object data depending on which gridfeld is calling for it
*
* @param Member $user
* @param string $fieldName
* @return DataList<WorkflowInstance>
*/
public function getFieldDependentData(Member $user, $fieldName)
{
Expand Down
2 changes: 2 additions & 0 deletions src/DataObjects/ImportedWorkflowTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowDefinition Definition()
*/
class ImportedWorkflowTemplate extends DataObject
{
Expand Down
5 changes: 5 additions & 0 deletions src/DataObjects/WorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\HasManyList;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
Expand All @@ -25,6 +26,10 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowDefinition WorkflowDef()
* @method Member Member()
* @method HasManyList<WorkflowTransition> Transitions()
*/
class WorkflowAction extends DataObject
{
Expand Down
6 changes: 5 additions & 1 deletion src/DataObjects/WorkflowActionInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
*
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkFlowInstance Workflow()
* @method WorkflowAction Baseaction()
* @method Member Member()
*/
class WorkflowActionInstance extends DataObject
{
Expand Down Expand Up @@ -181,7 +185,7 @@ public function getTitle()
* If this action returns only one valid transition it will be immediately
* followed; otherwise the user will decide which transition to follow.
*
* @return ArrayList
* @return ArrayList<WorkflowTransition>
*/
public function getValidTransitions()
{
Expand Down
7 changes: 7 additions & 0 deletions src/DataObjects/WorkflowDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
Expand All @@ -49,6 +51,11 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method HasManyList<WorkflowAction> Actions()
* @method HasManyList<WorkflowInstance> Instances()
* @method ManyManyList<Member> Users()
* @method ManyManyList<Group> Groups()
*/
class WorkflowDefinition extends DataObject
{
Expand Down
9 changes: 7 additions & 2 deletions src/DataObjects/WorkflowInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
Expand All @@ -41,6 +43,9 @@
* @method WorkflowDefinition Definition()
* @method WorkflowActionInstance CurrentAction()
* @method Member Initiator()
* @method HasManyList<WorkflowActionInstance> Actions()
* @method ManyManyList<Member> Users()
* @method ManyManyList<Group> Groups()
*
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
Expand Down Expand Up @@ -287,7 +292,7 @@ public function Target($getLive = false)
/**
* Returns the field differences between the older version and current version of Target
*
* @return ArrayList
* @return ArrayList<ArrayData>
*/
public function getTargetDiff()
{
Expand Down Expand Up @@ -481,7 +486,7 @@ public function performTransition(WorkflowTransition $transition)
* Returns a list of all Members that are assigned to this instance, either directly or via a group.
*
* @todo This could be made more efficient.
* @return ArrayList
* @return ArrayList<Member>
*/
public function getAssignedMembers()
{
Expand Down
10 changes: 7 additions & 3 deletions src/DataObjects/WorkflowTransition.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
Expand All @@ -27,11 +28,14 @@
* Therefore, any logic around whether the workflow can proceed should be
* managed within this method.
*
* @method WorkflowAction Action()
* @method WorkflowAction NextAction()
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowAction Action()
* @method WorkflowAction NextAction()
* @method ManyManyList<Member> Users()
* @method ManyManyList<Group> Groups()
*/
class WorkflowTransition extends DataObject
{
Expand Down Expand Up @@ -251,7 +255,7 @@ public function canDelete($member = null)
/**
* Returns a set of all Members that are assigned to this transition, either directly or via a group.
*
* @return ArrayList
* @return ArrayList<Member>
*/
public function getAssignedMembers()
{
Expand Down
5 changes: 3 additions & 2 deletions src/Extensions/AdvancedWorkflowExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\Form;
Expand All @@ -21,6 +22,8 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @extends Extension<RequestHandler>
*/
class AdvancedWorkflowExtension extends Extension
{
Expand Down Expand Up @@ -62,7 +65,6 @@ public function startworkflow($data, $form, $request)
public function updateEditForm(Form $form)
{
Requirements::javascript('symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js');
/** @var WorkflowService $service */
$service = singleton(WorkflowService::class);
/** @var DataObject|WorkflowApplicable $record */
$record = $form->getRecord();
Expand Down Expand Up @@ -127,7 +129,6 @@ public function updateItemEditForm($form)
*/
public function updateworkflow($data, Form $form, $request)
{
/** @var WorkflowService $service */
$service = singleton(WorkflowService::class);
/** @var DataObject $record */
$record = $form->getRecord();
Expand Down
9 changes: 8 additions & 1 deletion src/Extensions/WorkflowApplicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowActionInstance;
Expand All @@ -35,6 +37,11 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowDefinition WorkflowDefinition()
* @method ManyManyList<WorkflowDefinition> AdditionalWorkflowDefinitions()
*
* @extends DataExtension<DataObject&static>
*/
class WorkflowApplicable extends DataExtension
{
Expand Down Expand Up @@ -353,7 +360,7 @@ public function getWorkflowInstance()
/**
* Gets the history of a workflow instance
*
* @return DataList
* @return DataList<WorkflowActionInstance>|void
*/
public function getWorkflowHistory($limit = null)
{
Expand Down
7 changes: 6 additions & 1 deletion src/Extensions/WorkflowEmbargoExpiryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
*
* @author [email protected]
* @license BSD License http://silverstripe.org/bsd-license/
*
* @method QueuedJobDescriptor PublishJob()
* @method QueuedJobDescriptor UnPublishJob()
*
* @extends DataExtension<DataObject&static>
*/
class WorkflowEmbargoExpiryExtension extends DataExtension
{
Expand Down Expand Up @@ -293,7 +298,7 @@ public function onBeforeWrite()
if (!$this->owner->ID) {
return;
}

if ($this->owner->hasMethod('isPublishJobRunning') && $this->owner->isPublishJobRunning()) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Services/WorkflowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symbiote\AdvancedWorkflow\Extensions\FileWorkflowApplicable;
use Symbiote\AdvancedWorkflow\Extensions\WorkflowApplicable;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowActionInstance;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowDefinition;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowTransition;
Expand Down Expand Up @@ -199,7 +200,7 @@ public function getWorkflowFor($item, $includeComplete = false)
/**
* Get all the workflow action instances for an item
*
* @return DataList|null
* @return DataList<WorkflowActionInstance>|void
*/
public function getWorkflowHistoryFor($item, $limit = null)
{
Expand All @@ -212,7 +213,7 @@ public function getWorkflowHistoryFor($item, $limit = null)
/**
* Get all the available workflow definitions
*
* @return DataList
* @return DataList<WorkflowDefinition>
*/
public function getDefinitions()
{
Expand Down Expand Up @@ -297,11 +298,10 @@ public function startWorkflow(DataObject $object, $workflowID = null)
* Get all the workflows that this user is responsible for
*
* @param Member $user The user to get workflows for
* @return ArrayList The list of workflow instances this user owns
* @return ArrayList<WorkflowInstance> The list of workflow instances this user owns
*/
public function usersWorkflows(Member $user)
{

$groupIds = $user->Groups()->column('ID');

$groupInstances = null;
Expand Down Expand Up @@ -339,7 +339,7 @@ public function usersWorkflows(Member $user)
* Get items that the passed-in user has awaiting for them to action
*
* @param Member $member
* @return DataList
* @return DataList<WorkflowInstance>
*/
public function userPendingItems(Member $user)
{
Expand Down Expand Up @@ -367,7 +367,7 @@ public function userPendingItems(Member $user)
* Get items that the passed-in user has submitted for workflow review
*
* @param Member $member
* @return DataList
* @return DataList<WorkflowInstance>
*/
public function userSubmittedItems(Member $user)
{
Expand Down

0 comments on commit 1a35e0f

Please sign in to comment.