From 5b3bd5f09a8246d9dfd88a40610abd6ab07ab495 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 12 Jan 2024 16:37:28 +1300 Subject: [PATCH] ENH Add generic types --- src/Actions/AssignUsersToWorkflowAction.php | 5 ++++- src/Admin/AdvancedWorkflowAdmin.php | 9 ++++++--- src/DataObjects/ImportedWorkflowTemplate.php | 2 ++ src/DataObjects/WorkflowAction.php | 4 ++++ src/DataObjects/WorkflowActionInstance.php | 6 +++++- src/DataObjects/WorkflowDefinition.php | 5 +++++ src/DataObjects/WorkflowInstance.php | 7 +++++-- src/DataObjects/WorkflowTransition.php | 9 ++++++--- src/Extensions/AdvancedWorkflowExtension.php | 5 +++-- src/Extensions/WorkflowApplicable.php | 8 +++++++- src/Extensions/WorkflowEmbargoExpiryExtension.php | 7 ++++++- src/Services/WorkflowService.php | 12 ++++++------ 12 files changed, 59 insertions(+), 20 deletions(-) diff --git a/src/Actions/AssignUsersToWorkflowAction.php b/src/Actions/AssignUsersToWorkflowAction.php index 67cdc696..576727bf 100644 --- a/src/Actions/AssignUsersToWorkflowAction.php +++ b/src/Actions/AssignUsersToWorkflowAction.php @@ -20,6 +20,9 @@ * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow * @subpackage actions + * + * @method \SilverStripe\ORM\ManyManyList Users() + * @method \SilverStripe\ORM\ManyManyList Groups() */ class AssignUsersToWorkflowAction extends WorkflowAction { @@ -87,7 +90,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 */ public function getAssignedMembers() { diff --git a/src/Admin/AdvancedWorkflowAdmin.php b/src/Admin/AdvancedWorkflowAdmin.php index 17ac3788..d24cb41b 100644 --- a/src/Admin/AdvancedWorkflowAdmin.php +++ b/src/Admin/AdvancedWorkflowAdmin.php @@ -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; @@ -195,7 +197,7 @@ public function getEditForm($id = null, $fields = null) } $this->extend('updateEditFormAfter', $form); - + return $form; } @@ -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 * @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) @@ -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 */ public function getFieldDependentData(Member $user, $fieldName) { diff --git a/src/DataObjects/ImportedWorkflowTemplate.php b/src/DataObjects/ImportedWorkflowTemplate.php index 68691711..8411a450 100644 --- a/src/DataObjects/ImportedWorkflowTemplate.php +++ b/src/DataObjects/ImportedWorkflowTemplate.php @@ -11,6 +11,8 @@ * @author russell@silverstripe.com * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @method WorkflowDefinition Definition() */ class ImportedWorkflowTemplate extends DataObject { diff --git a/src/DataObjects/WorkflowAction.php b/src/DataObjects/WorkflowAction.php index c61ae5f0..05a91c01 100644 --- a/src/DataObjects/WorkflowAction.php +++ b/src/DataObjects/WorkflowAction.php @@ -25,6 +25,10 @@ * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @method WorkflowDefinition WorkflowDef() + * @method Member Member() + * @method \SilverStripe\ORM\HasManyList Transitions() */ class WorkflowAction extends DataObject { diff --git a/src/DataObjects/WorkflowActionInstance.php b/src/DataObjects/WorkflowActionInstance.php index 259b7be9..6ce8bedd 100644 --- a/src/DataObjects/WorkflowActionInstance.php +++ b/src/DataObjects/WorkflowActionInstance.php @@ -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 { @@ -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 */ public function getValidTransitions() { diff --git a/src/DataObjects/WorkflowDefinition.php b/src/DataObjects/WorkflowDefinition.php index 9e8360db..6ce33179 100644 --- a/src/DataObjects/WorkflowDefinition.php +++ b/src/DataObjects/WorkflowDefinition.php @@ -49,6 +49,11 @@ * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @method \SilverStripe\ORM\HasManyList Actions() + * @method \SilverStripe\ORM\HasManyList Instances() + * @method \SilverStripe\ORM\ManyManyList Users() + * @method \SilverStripe\ORM\ManyManyList Groups() */ class WorkflowDefinition extends DataObject { diff --git a/src/DataObjects/WorkflowInstance.php b/src/DataObjects/WorkflowInstance.php index 54c2b8f6..a0e89027 100644 --- a/src/DataObjects/WorkflowInstance.php +++ b/src/DataObjects/WorkflowInstance.php @@ -41,6 +41,9 @@ * @method WorkflowDefinition Definition() * @method WorkflowActionInstance CurrentAction() * @method Member Initiator() + * @method \SilverStripe\ORM\HasManyList Actions() + * @method \SilverStripe\ORM\ManyManyList Users() + * @method \SilverStripe\ORM\ManyManyList Groups() * * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) @@ -287,7 +290,7 @@ public function Target($getLive = false) /** * Returns the field differences between the older version and current version of Target * - * @return ArrayList + * @return ArrayList */ public function getTargetDiff() { @@ -481,7 +484,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 */ public function getAssignedMembers() { diff --git a/src/DataObjects/WorkflowTransition.php b/src/DataObjects/WorkflowTransition.php index 39937c9c..b3e86641 100644 --- a/src/DataObjects/WorkflowTransition.php +++ b/src/DataObjects/WorkflowTransition.php @@ -27,11 +27,14 @@ * Therefore, any logic around whether the workflow can proceed should be * managed within this method. * - * @method WorkflowAction Action() - * @method WorkflowAction NextAction() * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @method WorkflowAction Action() + * @method WorkflowAction NextAction() + * @method \SilverStripe\ORM\ManyManyList Users() + * @method \SilverStripe\ORM\ManyManyList Groups() */ class WorkflowTransition extends DataObject { @@ -251,7 +254,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 */ public function getAssignedMembers() { diff --git a/src/Extensions/AdvancedWorkflowExtension.php b/src/Extensions/AdvancedWorkflowExtension.php index 629b4ebe..255f1c3f 100644 --- a/src/Extensions/AdvancedWorkflowExtension.php +++ b/src/Extensions/AdvancedWorkflowExtension.php @@ -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; @@ -21,6 +22,8 @@ * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @extends Extension */ class AdvancedWorkflowExtension extends Extension { @@ -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(); @@ -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(); diff --git a/src/Extensions/WorkflowApplicable.php b/src/Extensions/WorkflowApplicable.php index 6debcbd3..249a58d0 100644 --- a/src/Extensions/WorkflowApplicable.php +++ b/src/Extensions/WorkflowApplicable.php @@ -19,6 +19,7 @@ use SilverStripe\ORM\CMSPreviewable; use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataList; +use SilverStripe\ORM\DataObject; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowActionInstance; @@ -35,6 +36,11 @@ * @author marcus@symbiote.com.au * @license BSD License (http://silverstripe.org/bsd-license/) * @package advancedworkflow + * + * @method WorkflowDefinition WorkflowDefinition() + * @method \SilverStripe\ORM\ManyManyList AdditionalWorkflowDefinitions() + * + * @extends DataExtension */ class WorkflowApplicable extends DataExtension { @@ -353,7 +359,7 @@ public function getWorkflowInstance() /** * Gets the history of a workflow instance * - * @return DataList + * @return DataList|void */ public function getWorkflowHistory($limit = null) { diff --git a/src/Extensions/WorkflowEmbargoExpiryExtension.php b/src/Extensions/WorkflowEmbargoExpiryExtension.php index f0d67443..d05242c8 100644 --- a/src/Extensions/WorkflowEmbargoExpiryExtension.php +++ b/src/Extensions/WorkflowEmbargoExpiryExtension.php @@ -35,6 +35,11 @@ * * @author marcus@symbiote.com.au * @license BSD License http://silverstripe.org/bsd-license/ + * + * @method QueuedJobDescriptor PublishJob() + * @method QueuedJobDescriptor UnPublishJob() + * + * @extends DataExtension */ class WorkflowEmbargoExpiryExtension extends DataExtension { @@ -293,7 +298,7 @@ public function onBeforeWrite() if (!$this->owner->ID) { return; } - + if ($this->owner->hasMethod('isPublishJobRunning') && $this->owner->isPublishJobRunning()) { return; } diff --git a/src/Services/WorkflowService.php b/src/Services/WorkflowService.php index e7eaf0c6..918a6b88 100644 --- a/src/Services/WorkflowService.php +++ b/src/Services/WorkflowService.php @@ -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; @@ -199,7 +200,7 @@ public function getWorkflowFor($item, $includeComplete = false) /** * Get all the workflow action instances for an item * - * @return DataList|null + * @return DataList|void */ public function getWorkflowHistoryFor($item, $limit = null) { @@ -212,7 +213,7 @@ public function getWorkflowHistoryFor($item, $limit = null) /** * Get all the available workflow definitions * - * @return DataList + * @return DataList */ public function getDefinitions() { @@ -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 The list of workflow instances this user owns */ public function usersWorkflows(Member $user) { - $groupIds = $user->Groups()->column('ID'); $groupInstances = null; @@ -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 */ public function userPendingItems(Member $user) { @@ -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 */ public function userSubmittedItems(Member $user) {