protected function doExecute(CommandInterface $modify_command, AggregateRootInterface $aggregate_root) { if (!$modify_command instanceof ModifyAggregateRootCommand) { throw new RuntimeError(sprintf('The %s only supports events that descend from %s', static::CLASS, ModifyAggregateRootCommand::CLASS)); } return $aggregate_root->modify($modify_command); }
protected function doExecute(CommandInterface $move_node_command, AggregateRootInterface $aggregate_root) { if (!$move_node_command instanceof MoveAggregateRootNodeCommand) { throw new RuntimeError(sprintf('The %s only supports events that inherit from %s', static::CLASS, MoveAggregateRootNodeCommand::CLASS)); } return $aggregate_root->moveNode($move_node_command); }
public function __construct($state_machine_name, AggregateRootInterface $aggregate_root) { $this->aggregate_root = $aggregate_root; $this->execution_context = new ExecutionContext($state_machine_name, $this->aggregate_root->getWorkflowState(), array_merge($aggregate_root->getWorkflowParameters(), ['current_state' => $this->aggregate_root->getWorkflowState()])); }
/** * @return array */ protected function getValidatedCommandValues(array $request_payload, AggregateRootInterface $aggregate_root) { return $this->processRequestPayload($request_payload, $aggregate_root->getType()); }
protected function populateAggregateRootTaskConflict(AggregateRootInterface $aggregate_root, AggregateRootEventList $aggregate_root_history, AggregateRootEventList $conflicting_events, array $conflicting_changes) { $service_locator = $this->getContext()->getServiceLocator(); $projection_type = $service_locator->getProjectionTypeMap()->getByAggregateRootType($this->getAggregateRootType()); $conflicted_projection = $projection_type->createEntity(array_merge($aggregate_root->toNative(), $conflicting_changes)); $current_aggregate_root = $this->createAggregateRootFromHistory($aggregate_root_history); $timestamps['created_at'] = $aggregate_root_history->getFirst()->getIsoDate(); $timestamps['modified_at'] = $aggregate_root_history->getLast()->getIsoDate(); $current_projection = $projection_type->createEntity(array_merge($current_aggregate_root->toNative(), $timestamps)); $task_conflict = new TaskConflict(['current_resource' => $current_projection, 'conflicted_resource' => $conflicted_projection, 'conflicting_events' => $conflicting_events, 'conflicting_attribute_names' => array_keys($conflicting_changes)]); $service_locator->getTaskService()->addTaskConflict($task_conflict); }
protected function doExecute(CommandInterface $command, AggregateRootInterface $user) { return $user->enablePasswordReset($command); }
protected function doExecute(CommandInterface $command, AggregateRootInterface $user) { return $user->changePassword($command); }