diff --git a/.github/workflows/backend-ci.yaml b/.github/workflows/backend-ci.yaml index 892eac04..39ca160a 100644 --- a/.github/workflows/backend-ci.yaml +++ b/.github/workflows/backend-ci.yaml @@ -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 @@ -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 @@ -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 diff --git a/composer.json b/composer.json index ea191ee9..1c0ea8c4 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -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", diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 00000000..1321c2be --- /dev/null +++ b/dependencies.json @@ -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 + } + ] +} \ No newline at end of file diff --git a/src/bundle/Resources/config/services.yaml b/src/bundle/Resources/config/services.yaml index f2b92354..cdfc0660 100644 --- a/src/bundle/Resources/config/services.yaml +++ b/src/bundle/Resources/config/services.yaml @@ -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 } diff --git a/src/lib/Form/Processor/ContentFormProcessor.php b/src/lib/Form/Processor/ContentFormProcessor.php index 0222971f..86a06951 100644 --- a/src/lib/Form/Processor/ContentFormProcessor.php +++ b/src/lib/Form/Processor/ContentFormProcessor.php @@ -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; @@ -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, ) { } @@ -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)); diff --git a/tests/integration/Kernel.php b/tests/integration/Kernel.php index cd9309b7..6a8f0d6e 100644 --- a/tests/integration/Kernel.php +++ b/tests/integration/Kernel.php @@ -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; @@ -19,6 +20,7 @@ public function registerBundles(): iterable yield from parent::registerBundles(); yield new IbexaContentFormsBundle(); + yield new IbexaMessengerBundle(); } public function registerContainerConfiguration(LoaderInterface $loader): void