Skip to content
Draft
75 changes: 33 additions & 42 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ jobs:
- '8.3'

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: 'pdo_sqlite, gd'
tools: cs2pr
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}

- uses: ./.github/actions/composer-install

- name: Run code style check
run: composer run-script check-cs -- --format=checkstyle | cs2pr
- name: Run code style check
run: composer run-script check-cs -- --format=checkstyle | cs2pr

tests:
name: Unit tests & PHPStan static analysis
Expand All @@ -45,26 +42,23 @@ jobs:
- '8.4'

steps:
- uses: actions/checkout@v5

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: pdo_sqlite, gd
tools: cs2pr
- uses: actions/checkout@v6

- uses: ./.github/actions/composer-install
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run unit test suite
run: composer test
- name: Run unit test suite
run: composer test

- name: Run PHPStan analysis
run: composer run-script phpstan
- name: Run PHPStan analysis
run: composer run-script phpstan

integration-tests:
name: Runs integration tests
Expand All @@ -80,20 +74,17 @@ jobs:
- '8.4'

steps:
- uses: actions/checkout@v5

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: pdo_sqlite, gd
tools: cs2pr
- uses: actions/checkout@v6

- uses: ./.github/actions/composer-install
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run unit test suite
run: composer run-script test-integration
- name: Run unit test suite
run: composer run-script test-integration
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ibexa/content-forms",
"description": "Use Symfony Forms with Ibexa Content & User objects",
"minimum-stability": "dev",
"license": "(GPL-2.0-only or proprietary)",
"type": "ibexa-bundle",
"replace": {
Expand All @@ -10,6 +11,7 @@
"php": " >=8.3",
"ext-json": "*",
"ibexa/core": "~6.0.x-dev",
"ibexa/messenger": "~6.0.x-dev",
"symfony/config": "^7.4",
"symfony/dependency-injection": "^7.4",
"symfony/event-dispatcher": "^7.4",
Expand Down
11 changes: 11 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recipesEndpoint": "",
"packages": [
{
"requirement": "dev-IBX-11780-async-content-publishing-spike as 6.0.x-dev",
"repositoryUrl": "https://github.com/ibexa/core",
"package": "ibexa/core",
"shouldBeAddedAsVCS": false
}
]
}
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ services:
- '@ibexa.api.service.content'
- '@ibexa.api.service.location'
- '@router'
- '@Ibexa\Contracts\Core\Repository\ContentPublisherInterface'
- '@ibexa.config.resolver'
tags:
- { name: kernel.event_subscriber }

Expand Down
26 changes: 17 additions & 9 deletions src/lib/Form/Processor/ContentFormProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
use Ibexa\ContentForms\Data\NewnessCheckable;
use Ibexa\ContentForms\Event\ContentFormEvents;
use Ibexa\ContentForms\Event\FormActionEvent;
use Ibexa\Contracts\Core\Repository\ContentPublisherInterface;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\Base\Exceptions\InvalidArgumentException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand All @@ -33,7 +35,9 @@
public function __construct(
private ContentService $contentService,
private LocationService $locationService,
private RouterInterface $router
private RouterInterface $router,
private ContentPublisherInterface $contentPublisher,
private ConfigResolverInterface $configResolver,
) {
}

Expand Down Expand Up @@ -150,26 +154,30 @@ public function processPublish(FormActionEvent $event): void

$draft = $this->saveDraft($data, $form->getConfig()->getOption('languageCode'));
$versionInfo = $draft->getVersionInfo();
$content = $this->contentService->publishVersion(

$this->contentPublisher->publishVersion(
$versionInfo,
[$versionInfo->getInitialLanguage()->getLanguageCode()]
[$versionInfo->getInitialLanguage()->getLanguageCode()],
);

$event->setPayload('content', $content);
$event->setPayload('content_type', $draft->getContentType());
$event->setPayload('is_new', $draft->getContentInfo()->isDraft());

$locationId = $referrerLocation !== null && $data instanceof ContentUpdateData
? $referrerLocation->id
: $content->getContentInfo()->getMainLocationId();
if ($referrerLocation !== null && $data instanceof ContentUpdateData) {
$locationId = $referrerLocation->id;
$contentId = $draft->getContentInfo()->id;
} else {
$locationId = (int) $this->configResolver->getParameter('location_ids.content_structure');
$contentId = $this->locationService->loadLocation($locationId)->getContentId();
}

$contentId = $content->getId();
$redirectUrl = $form['redirectUrlAfterPublish']->getData() ?: $this->router->generate(
'ibexa.content.view',
[
'contentId' => $contentId,
'locationId' => $locationId,
'publishedContentId' => $contentId,
]
],
);

$event->setResponse(new RedirectResponse($redirectUrl));
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Ibexa\Tests\Integration\ContentForms;

use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle;
use Ibexa\Bundle\Messenger\IbexaMessengerBundle;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

Expand All @@ -19,6 +20,7 @@ public function registerBundles(): iterable
yield from parent::registerBundles();

yield new IbexaContentFormsBundle();
yield new IbexaMessengerBundle();
}

public function registerContainerConfiguration(LoaderInterface $loader): void
Expand Down
Loading