Skip to content
Merged
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
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ parameters:
-
message: '#^Cannot access property \$languageCode on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#'
identifier: property.nonObject
count: 4
count: 5
path: src/bundle/Controller/ContentController.php

-
Expand Down
14 changes: 14 additions & 0 deletions src/bundle/Controller/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Ibexa\AdminUi\Specification\ContentIsUser;
use Ibexa\AdminUi\Specification\ContentType\ContentTypeIsUser;
use Ibexa\Contracts\AdminUi\Controller\Controller;
use Ibexa\Contracts\AdminUi\Event\ContentEditEvent;
use Ibexa\Contracts\AdminUi\Event\ContentProxyCreateEvent;
use Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface;
use Ibexa\Contracts\Core\Limitation\Target;
Expand Down Expand Up @@ -242,6 +243,19 @@ public function editAction(Request $request): Response
]);
}

/** @var \Ibexa\Contracts\AdminUi\Event\ContentEditEvent $event */
$event = $this->eventDispatcher->dispatch(
new ContentEditEvent(
$content,
$versionInfo,
$language->languageCode
)
);

if ($event->hasResponse()) {
return $event->getResponse();
}

if (!$versionInfo->isDraft()) {
$contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo, null, $language);
$versionNo = $contentDraft->getVersionInfo()->versionNo;
Expand Down
68 changes: 68 additions & 0 deletions src/contracts/Event/ContentEditEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Contracts\AdminUi\Event;

use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @internal
*/
final class ContentEditEvent extends Event
{
private ?Response $response = null;

private Content $content;

private VersionInfo $versionInfo;

private string $languageCode;

public function __construct(
Content $content,
VersionInfo $versionInfo,
string $languageCode
) {
$this->content = $content;
$this->versionInfo = $versionInfo;
$this->languageCode = $languageCode;
}

public function getContent(): Content
{
return $this->content;
}

public function getVersionInfo(): VersionInfo
{
return $this->versionInfo;
}

public function getLanguageCode(): string
{
return $this->languageCode;
}

public function getResponse(): ?Response
{
return $this->response;
}

public function setResponse(Response $response): void
{
$this->response = $response;
}

public function hasResponse(): bool
{
return !empty($this->response);
}
}
Loading