Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
$output->writeln('Moved ' . $content->getName() . ' through transition ' . $transitionName);
}

$versionInfo = $content->getVersionInfo();
$workflowMetadataByVersion = $this->workflowService->loadWorkflowMetadataForVersionInfo($versionInfo, $workflowName);

Check warning on line 67 in code_samples/api/public_php_api/src/Command/WorkflowCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "$workflowMetadataByVersion" local variable.

See more on https://sonarcloud.io/project/issues?id=ezsystems_developer-documentation&issues=AZ39QiJFp2xk0uG8PvHN&open=AZ39QiJFp2xk0uG8PvHN&pullRequest=3186

return self::SUCCESS;
}
}
27 changes: 18 additions & 9 deletions docs/content_management/workflow/workflow_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Workflow API

You can manage [workflows](workflow.md) with PHP API by using `WorkflowServiceInterface`.
You can manage [workflows](workflow.md) with PHP API by using [`WorkflowServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html).

## Workflow service

Expand All @@ -22,36 +22,45 @@

## Getting workflow information

To get information about a specific workflow for a content item, use `WorkflowServiceInterface::loadWorkflowMetadataForContent`:
To get information about a specific workflow for a content item, use [`WorkflowServiceInterface::loadWorkflowMetadataForContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_loadWorkflowMetadataForContent):

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 53, 57) =]]
[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 54, 58, remove_indent=True) =]]
```

!!! tip

`marking`, a term from [Symfony Workflow]([[= symfony_doc =]]/components/workflow.html),
refers to a state in a workflow.

To get a list of all workflows that can be used for a given content item, use `WorkflowRegistry`:
If you already have a [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object,

Check notice on line 36 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L36

[Ibexa.SentenceLength] Keep your sentences to less than 30 words.
Raw output
{"message": "[Ibexa.SentenceLength] Keep your sentences to less than 30 words.", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 36, "column": 1}}}, "severity": "INFO"}

Check warning on line 36 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L36

[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.
Raw output
{"message": "[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 36, "column": 150}}}, "severity": "WARNING"}
use [`WorkflowServiceInterface::loadWorkflowMetadataForVersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_loadWorkflowMetadataForVersionInfo) to avoid loading the full [`Content`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html),
This method is more efficient when iterating over draft versions:

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48) =]]
[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 66, 67, remove_indent=True) =]]
```

To get a list of all workflows that can be used for a given content item, use [`WorkflowRegistryInterface::getSupportedWorkflows`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Registry-WorkflowRegistryInterface.html#method_getSupportedWorkflows):

Check notice on line 44 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L44

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 44, "column": 41}}}, "severity": "INFO"}

``` php
[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 48, 48, remove_indent=True) =]]
```

## Applying workflow transitions

To place a content item in a workflow, use `WorkflowService::start`:
To place a content item in a workflow, use [`WorkflowServiceInterface::start`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_start):

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 52, 53) =]]
[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 53, 53, remove_indent=True) =]]
```

To apply a transition to a content item, use `Workflow::apply`.
Additionally, you can check if the transition is possible for the given object using `WorkflowService::can`:
Additionally, you can check if the transition is possible for the given object using [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can):

Check notice on line 59 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L59

[Ibexa.Whether] Consider replacing 'if' with 'whether' for clarity
Raw output
{"message": "[Ibexa.Whether] Consider replacing 'if' with 'whether' for clarity", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 59, "column": 23}}}, "severity": "INFO"}

Check notice on line 59 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L59

[Ibexa.ByUsing] Prefer 'by using' or 'with' to plain 'using'.
Raw output
{"message": "[Ibexa.ByUsing] Prefer 'by using' or 'with' to plain 'using'.", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 59, "column": 73}}}, "severity": "INFO"}

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 59, 62) =]] }
[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 61, 62, remove_indent=True) =]]

Check warning on line 62 in docs/content_management/workflow/workflow_api.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/workflow/workflow_api.md#L62

[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.
Raw output
{"message": "[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.", "location": {"path": "docs/content_management/workflow/workflow_api.md", "range": {"start": {"line": 62, "column": 116}}}, "severity": "WARNING"}
}
```

!!! tip
Expand Down
Loading