Skip to content

API doc for loadWorkflowMetadataForVersionInfo#3186

Open
mnocon wants to merge 7 commits into
4.6from
ibx-11494-optimize-version-tab
Open

API doc for loadWorkflowMetadataForVersionInfo#3186
mnocon wants to merge 7 commits into
4.6from
ibx-11494-optimize-version-tab

Conversation

@mnocon
Copy link
Copy Markdown
Contributor

@mnocon mnocon commented May 6, 2026

Target: 4.6 and higher

Doc for https://github.com/ibexa/workflow/pull/177

Status: wait for next release (4.6 and 5.0)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Preview of modified files

Preview of modified Markdown:

@mnocon mnocon force-pushed the ibx-11494-optimize-version-tab branch from daeaf71 to 7c61ccb Compare May 6, 2026 12:45
@mnocon mnocon requested review from barw4 and micszo May 7, 2026 07:36
Copy link
Copy Markdown
Contributor

@micszo micszo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mnocon mnocon requested a review from a team May 7, 2026 13:11
@ibexa-workflow-automation-1 ibexa-workflow-automation-1 Bot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team May 7, 2026 13:12
@mnocon mnocon mentioned this pull request May 11, 2026
7 tasks

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),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

Comment thread docs/content_management/workflow/workflow_api.md Outdated

``` 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) =]]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider including lines 60 to 64 to show the can method, too

mnocon and others added 3 commits May 11, 2026 18:42
Co-authored-by: Tomasz Dąbrowski <64841871+dabrt@users.noreply.github.com>
@mnocon
Copy link
Copy Markdown
Contributor Author

mnocon commented May 11, 2026

Thank you @dabrt , suggestions applied in 19b7c33 , 04ec0bd , and 7fe47c2

@mnocon mnocon added Wait with merge PRs that shouldn't be merged instantly Ready for MERGE and removed Needs DOC review labels May 11, 2026
@github-actions
Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/api/public_php_api/src/Command/WorkflowCommand.php

docs/content_management/workflow/workflow_api.md@27:``` php

code_samples/api/public_php_api/src/Command/WorkflowCommand.php

docs/content_management/workflow/workflow_api.md@27:``` php
docs/content_management/workflow/workflow_api.md@28:[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 53, 57) =]]
docs/content_management/workflow/workflow_api.md@28:[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 54, 58, remove_indent=True) =]]
docs/content_management/workflow/workflow_api.md@29:```

docs/content_management/workflow/workflow_api.md@29:```

001⫶        $workflowMetadata = $this->workflowService->loadWorkflowMetadataForContent($content, $workflowName);
001⫶$workflowMetadata = $this->workflowService->loadWorkflowMetadataForContent($content, $workflowName);
002⫶
002⫶
003⫶        foreach ($workflowMetadata->markings as $marking) {
004⫶ $output->writeln($content->getName() . ' is in stage ' . $marking->name . ' in workflow ' . $workflowMetadata->workflow->getName());
003⫶foreach ($workflowMetadata->markings as $marking) {
004⫶ $output->writeln($content->getName() . ' is in stage ' . $marking->name . ' in workflow ' . $workflowMetadata->workflow->getName());
005⫶}

docs/content_management/workflow/workflow_api.md@39:``` php
docs/content_management/workflow/workflow_api.md@40:[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 66, 67, remove_indent=True) =]]
docs/content_management/workflow/workflow_api.md@41:```

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

docs/content_management/workflow/workflow_api.md@45:``` php
docs/content_management/workflow/workflow_api.md@46:[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 48, 48, remove_indent=True) =]]
docs/content_management/workflow/workflow_api.md@47:```


docs/content_management/workflow/workflow_api.md@38:``` php
docs/content_management/workflow/workflow_api.md@39:[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 47, 48) =]]
docs/content_management/workflow/workflow_api.md@40:```

001⫶ $supportedWorkflows = $this->workflowRegistry->getSupportedWorkflows($content);

docs/content_management/workflow/workflow_api.md@46:``` php
docs/content_management/workflow/workflow_api.md@47:[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 52, 53) =]]
docs/content_management/workflow/workflow_api.md@48:```

001⫶ $this->workflowService->start($content, $workflowName);
001⫶$supportedWorkflows = $this->workflowRegistry->getSupportedWorkflows($content);

docs/content_management/workflow/workflow_api.md@53:``` php

docs/content_management/workflow/workflow_api.md@53:``` php
docs/content_management/workflow/workflow_api.md@54:[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 59, 62) =]]    }
docs/content_management/workflow/workflow_api.md@54:[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 53, 53, remove_indent=True) =]]
docs/content_management/workflow/workflow_api.md@55:```

docs/content_management/workflow/workflow_api.md@55:```

001⫶        if ($this->workflowService->can($workflowMetadata, $transitionName)) {
002⫶ $workflow = $this->workflowRegistry->getWorkflow($workflowName);
003⫶ $workflow->apply($workflowMetadata->content, $transitionName, ['message' => 'done', 'reviewerId' => 14]);
004⫶ }
001⫶$this->workflowService->start($content, $workflowName);

docs/content_management/workflow/workflow_api.md@60:``` php
docs/content_management/workflow/workflow_api.md@61:[[= include_code('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 60, 64, remove_indent=True) =]]
docs/content_management/workflow/workflow_api.md@62:```

001⫶if ($this->workflowService->can($workflowMetadata, $transitionName)) {
002⫶ $workflow = $this->workflowRegistry->getWorkflow($workflowName);
003⫶ $workflow->apply($workflowMetadata->content, $transitionName, ['message' => 'done', 'reviewerId' => 14]);
004⫶ $output->writeln('Moved ' . $content->getName() . ' through transition ' . $transitionName);
005⫶}


Download colorized diff

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for MERGE Wait with merge PRs that shouldn't be merged instantly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants