From 7c61ccb162c9db7337cc1fcdd1bef97c5fb5b1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 6 May 2026 14:15:53 +0200 Subject: [PATCH 1/7] API doc for loadWorkflowMetadataForVersionInfo --- .../src/Command/WorkflowCommand.php | 3 +++ .../workflow/workflow_api.md | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index f36d877a77..485ee6e4f9 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -63,6 +63,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Moved ' . $content->getName() . ' through transition ' . $transitionName); } + $versionInfo = $content->getVersionInfo(); + $workflowMetadataByVersion = $this->workflowService->loadWorkflowMetadataForVersionInfo($versionInfo, $workflowName); + return self::SUCCESS; } } diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index d7b1770f9a..6872f4f803 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -4,7 +4,7 @@ description: PHP API enables you to get workflow information and apply specific # 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 @@ -22,7 +22,7 @@ but the implementation in workflow service extends them, for example by providin ## 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) =]] @@ -33,7 +33,15 @@ To get information about a specific workflow for a content item, use `WorkflowSe `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, +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', 65, 67) =]] +``` + +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): ``` php [[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48) =]] @@ -41,14 +49,14 @@ To get a list of all workflows that can be used for a given content item, use `W ## 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) =]] ``` 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): ``` php [[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 59, 62) =]] } From 9663c451eb95e528428a27ae9ad5eb2e1aa2ffb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 6 May 2026 16:42:57 +0200 Subject: [PATCH 2/7] Self review --- docs/content_management/workflow/workflow_api.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index 6872f4f803..ca20bd2a20 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -25,7 +25,7 @@ but the implementation in workflow service extends them, for example by providin 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) =]] ``` !!! tip @@ -59,7 +59,8 @@ 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 [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can): ``` 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', 60, 62, remove_indent=True) =]] +} ``` !!! tip From eab5f8bc28d8087cfcac22a7e43824efeee8d9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 7 May 2026 09:27:03 +0200 Subject: [PATCH 3/7] Removed Indent --- docs/content_management/workflow/workflow_api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index ca20bd2a20..da756b5592 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -25,7 +25,7 @@ but the implementation in workflow service extends them, for example by providin 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_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 54, 58) =]] +[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 54, 58, remove_indent=True) =]] ``` !!! tip @@ -38,13 +38,13 @@ use [`WorkflowServiceInterface::loadWorkflowMetadataForVersionInfo`](/api/php_ap This method is more efficient when iterating over draft versions: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 65, 67) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 65, 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): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48, remove_indent=True) =]] ``` ## Applying workflow transitions @@ -52,7 +52,7 @@ To get a list of all workflows that can be used for a given content item, use [` 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_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 52, 53, remove_indent=True) =]] ``` To apply a transition to a content item, use `Workflow::apply`. From eeac5b0732c9e0937e56e8e5701b4f2c76fea8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 7 May 2026 15:06:13 +0200 Subject: [PATCH 4/7] Migrate to include_code --- docs/content_management/workflow/workflow_api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index da756b5592..eb5648700a 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -38,13 +38,13 @@ use [`WorkflowServiceInterface::loadWorkflowMetadataForVersionInfo`](/api/php_ap This method is more efficient when iterating over draft versions: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 65, 67, remove_indent=True) =]] +[[= 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): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48, remove_indent=True) =]] +[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 48, 48, remove_indent=True) =]] ``` ## Applying workflow transitions @@ -52,14 +52,14 @@ To get a list of all workflows that can be used for a given content item, use [` 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, remove_indent=True) =]] +[[= 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 [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can): ``` php -[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 60, 62, remove_indent=True) =]] +[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 61, 62, remove_indent=True) =]] } ``` From 19b7c33a8d217085839a8d80ee6705556d1ce027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 11 May 2026 18:42:54 +0200 Subject: [PATCH 5/7] Fixed code sample include --- docs/content_management/workflow/workflow_api.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index eb5648700a..48ce58cd87 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -59,8 +59,7 @@ 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 [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can): ``` php -[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 61, 62, remove_indent=True) =]] -} +[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 60, 64, remove_indent=True) =]] ``` !!! tip From 04ec0bddf8745d65e03e93adac9f6b2b73d9757f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 11 May 2026 18:43:51 +0200 Subject: [PATCH 6/7] Review fixes --- docs/content_management/workflow/workflow_api.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index 48ce58cd87..f64d9fa92c 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -33,8 +33,7 @@ To get information about a specific workflow for a content item, use [`WorkflowS `marking`, a term from [Symfony Workflow]([[= symfony_doc =]]/components/workflow.html), refers to a state in a workflow. -If you already have a [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object, -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), +If you already have a [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object, 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 From 7fe47c27e982dac2979a14f1b5ce24ea398a6405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 11 May 2026 18:44:34 +0200 Subject: [PATCH 7/7] Apply suggestion from @dabrt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomasz DÄ…browski <64841871+dabrt@users.noreply.github.com> --- docs/content_management/workflow/workflow_api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index f64d9fa92c..61d4ac61f5 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -55,7 +55,7 @@ To place a content item in a workflow, use [`WorkflowServiceInterface::start`](/ ``` 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 [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can): +Additionally, you can check if the transition is possible for the given object by using [`WorkflowServiceInterface::can`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Workflow-Service-WorkflowServiceInterface.html#method_can): ``` php [[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 60, 64, remove_indent=True) =]]