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 12, 2024
1 parent a12a4f2 commit 5b3bd5f
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/Actions/AssignUsersToWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
* @subpackage actions
*
* @method \SilverStripe\ORM\ManyManyList<Member> Users()
* @method \SilverStripe\ORM\ManyManyList<Group> Groups()
*/
class AssignUsersToWorkflowAction extends WorkflowAction
{
Expand Down Expand Up @@ -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<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
4 changes: 4 additions & 0 deletions src/DataObjects/WorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowDefinition WorkflowDef()
* @method Member Member()
* @method \SilverStripe\ORM\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
5 changes: 5 additions & 0 deletions src/DataObjects/WorkflowDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method \SilverStripe\ORM\HasManyList<WorkflowAction> Actions()
* @method \SilverStripe\ORM\HasManyList<WorkflowInstance> Instances()
* @method \SilverStripe\ORM\ManyManyList<Member> Users()
* @method \SilverStripe\ORM\ManyManyList<Group> Groups()
*/
class WorkflowDefinition extends DataObject
{
Expand Down
7 changes: 5 additions & 2 deletions src/DataObjects/WorkflowInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
* @method WorkflowDefinition Definition()
* @method WorkflowActionInstance CurrentAction()
* @method Member Initiator()
* @method \SilverStripe\ORM\HasManyList<WorkflowActionInstance> Actions()
* @method \SilverStripe\ORM\ManyManyList<Member> Users()
* @method \SilverStripe\ORM\ManyManyList<Group> Groups()
*
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
Expand Down Expand Up @@ -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<ArrayData>
*/
public function getTargetDiff()
{
Expand Down Expand Up @@ -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<Member>
*/
public function getAssignedMembers()
{
Expand Down
9 changes: 6 additions & 3 deletions src/DataObjects/WorkflowTransition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowAction Action()
* @method WorkflowAction NextAction()
* @method \SilverStripe\ORM\ManyManyList<Member> Users()
* @method \SilverStripe\ORM\ManyManyList<Group> Groups()
*/
class WorkflowTransition extends DataObject
{
Expand Down Expand Up @@ -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<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
8 changes: 7 additions & 1 deletion src/Extensions/WorkflowApplicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +36,11 @@
* @author [email protected]
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*
* @method WorkflowDefinition WorkflowDefinition()
* @method \SilverStripe\ORM\ManyManyList<WorkflowDefinition> AdditionalWorkflowDefinitions()
*
* @extends DataExtension<DataObject&static>
*/
class WorkflowApplicable extends DataExtension
{
Expand Down Expand Up @@ -353,7 +359,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 5b3bd5f

Please sign in to comment.