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

[WIP] Multiple paths improvements #68

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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: 3 additions & 3 deletions src/Definition/Bpmn2Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function read($file)
*
* @throws IdAttributeNotFoundException
*
* @since Method available since Release 1.3.0
* @since 1.3.0
*/
public function readSource($source)
{
Expand All @@ -63,7 +63,7 @@ public function readSource($source)
*
* @throws IdAttributeNotFoundException
*
* @since Method available since Release 1.3.0
* @since 1.3.0
*/
private function readDocument(\DOMDocument $document, $workflowId = null)
{
Expand Down Expand Up @@ -251,7 +251,7 @@ private function createIdAttributeNotFoundException(\DOMElement $element, $workf
*
* @return string
*
* @since Method available since Release 1.3.0
* @since 1.3.0
*/
private function provideRoleIdForFlowObject(array $flowObjectRoles, $flowObjectId)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class Process
/**
* @var ExpressionLanguage
*
* @since Property available since Release 1.2.0
* @since 1.2.0
*/
private $expressionLanguage;

/**
* @var OperationRunnerInterface
*
* @since Property available since Release 1.2.0
* @since 1.2.0
*/
private $operationRunner;

Expand All @@ -61,7 +61,7 @@ public function __construct($workflowContext, WorkflowRepositoryInterface $workf
/**
* @param ExpressionLanguage $expressionLanguage
*
* @since Method available since Release 1.2.0
* @since 1.2.0
*/
public function setExpressionLanguage(ExpressionLanguage $expressionLanguage)
{
Expand Down Expand Up @@ -143,14 +143,14 @@ public function executeWorkItem(WorkItemContextInterface $workItemContext)
if ($activity->isAllocatable()) {
$this->allocateWorkItem($workItemContext);
$nextWorkItemContext = new WorkItemContext($workItemContext->getParticipant());
$nextWorkItemContext->setActivityId($workItemContext->getProcessContext()->getWorkflow()->getCurrentFlowObject()->getId());
$nextWorkItemContext->setActivityId($workItemContext->getActivityId());
$nextWorkItemContext->setProcessContext($workItemContext->getProcessContext());

return $this->executeWorkItem($nextWorkItemContext);
} elseif ($activity->isStartable()) {
$this->startWorkItem($workItemContext);
$nextWorkItemContext = new WorkItemContext($workItemContext->getParticipant());
$nextWorkItemContext->setActivityId($workItemContext->getProcessContext()->getWorkflow()->getCurrentFlowObject()->getId());
$nextWorkItemContext->setActivityId($workItemContext->getActivityId());
$nextWorkItemContext->setProcessContext($workItemContext->getProcessContext());

return $this->executeWorkItem($nextWorkItemContext);
Expand All @@ -164,7 +164,7 @@ public function executeWorkItem(WorkItemContextInterface $workItemContext)
/**
* @return int|string|WorkflowContextInterface
*
* @since Method available since Release 1.1.0
* @since 1.1.0
*/
public function getWorkflowContext()
{
Expand Down Expand Up @@ -192,7 +192,7 @@ private function createWorkflow()
*
* @return Workflow
*
* @since Method available since Release 1.2.0
* @since 1.2.0
*/
private function configureWorkflow(Workflow $workflow)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Process/WorkItemContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getActivityId()
/**
* @param ParticipantInterface $participant
*
* @since Method available since Release 1.1.0
* @since 1.1.0
*/
public function setParticipant(ParticipantInterface $participant)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Process/WorkflowContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace PHPMentors\Workflower\Process;

/**
* @since Interface available since Release 1.1.0
* @since 1.1.0
*/
interface WorkflowContextInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Activity/SendTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHPMentors\Workflower\Workflow\Resource\MessageInterface;

/**
* @since Class available since Release 1.3.0
* @since 1.3.0
*/
class SendTask extends Task implements MessageInterface, OperationalInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Activity/ServiceTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use PHPMentors\Workflower\Workflow\Participant\Role;

/**
* @since Class available since Release 1.2.0
* @since 1.2.0
*/
class ServiceTask extends Task implements OperationalInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Activity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Task implements ActivityInterface, \Serializable
/**
* @var Token
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $token;

Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Element/ConnectingObjectCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function filterBySource(TransitionalInterface $flowObject)
*
* @return ConnectingObjectCollection
*
* @since Method available since Release 2.0.0
* @since 2.0.0
*/
public function filterByDestination(TransitionalInterface $flowObject): ConnectingObjectCollection
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Element/FlowObjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface FlowObjectInterface extends RoleAwareInterface, WorkflowElementInterfa
/**
* @param Token $token
*
* @since Method available since Release 2.0.0
* @since 2.0.0
*/
public function attachToken(Token $token): void;
}
6 changes: 3 additions & 3 deletions src/Workflow/Event/EndEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ class EndEvent extends Event implements EventInterface
/**
* @var Token
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $token;

/**
* @var \DateTime
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $endDate;

/**
* {@inheritdoc}
*
* @since Method available since Release 2.0.0
* @since 2.0.0
*/
public function serialize()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Workflow/Event/StartEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ class StartEvent extends Event implements EventInterface, TransitionalInterface,
/**
* @var Token
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $token;

/**
* @var \DateTime
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $startDate;

/**
* {@inheritdoc}
*
* @since Method available since Release 2.0.0
* @since 2.0.0
*/
public function serialize()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Gateway/ExclusiveGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ExclusiveGateway implements GatewayInterface, ConditionalInterface, \Seria
/**
* @var Token
*
* @since Property available since Release 2.0.0
* @since 2.0.0
*/
private $token;

Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Gateway/ParallelGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use PHPMentors\Workflower\Workflow\Participant\Role;

/**
* @since Class available since Release 2.0.0
* @since 2.0.0
*/
class ParallelGateway implements GatewayInterface, \Serializable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Operation/OperationRunnerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use PHPMentors\Workflower\Workflow\Workflow;

/**
* @since Interface available since Release 1.2.0
* @since 1.2.0
*/
interface OperationRunnerInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Operation/OperationalInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace PHPMentors\Workflower\Workflow\Operation;

/**
* @since Interface available since Release 1.2.0
* @since 1.2.0
*/
interface OperationalInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow/Resource/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace PHPMentors\Workflower\Workflow\Resource;

/**
* @since Interface available since Release 1.3.0
* @since 1.3.0
*/
interface MessageInterface
{
Expand Down
46 changes: 46 additions & 0 deletions src/Workflow/TokenRegistry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/*
* Copyright (c) Atsuhiro Kubo <[email protected]> and contributors,
* All rights reserved.
*
* This file is part of Workflower.
*
* This program and the accompanying materials are made available under
* the terms of the BSD 2-Clause License which accompanies this
* distribution, and is available at http://opensource.org/licenses/BSD-2-Clause
*/

namespace PHPMentors\Workflower\Workflow;

use PHPMentors\Workflower\Workflow\Element\Token;
use PHPMentors\Workflower\Workflow\Event\EndEvent;

/**
* @since 2.0.0
*/
class TokenRegistry
{
private $tokens = [];

public function register(Token $token): void
{
$this->tokens[$token->getId()] = $token;
}

public function remove(Token $token): void
{
unset($this->tokens[$token->getId()]);
}

public function getTokens(): array
{
return array_values($this->tokens);
}

public function getActiveTokens(): array
{
return array_values(array_filter($this->tokens, function (Token $token) {
return !($token->getCurrentFlowObject() instanceof EndEvent);
}));
}
}
Loading