-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBX-5905: Implemented LoadContent events #250
Open
mateuszdebinski
wants to merge
8
commits into
4.6
Choose a base branch
from
IBX-5905_content_type_identifier_in_contentInfo
base: 4.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4eae46a
IBX-5905: Added content type identifier to ContentInfo
mateuszdebinski f313a56
Changed naming & query building, tests adapted to changes
mateuszdebinski 4085781
Removed unnecessary tests, Added exclusions for sonar cloud
mateuszdebinski 4460b5c
Removed unnecessary tests, Added exclusions for sonar cloud
mateuszdebinski 472b69b
Removed sonar-project.properties
mateuszdebinski 04c4bac
Added declaring strict types.
mateuszdebinski a94c6b8
Added BeforeLoadContentEvent
mateuszdebinski 63485b4
Corrected CS
mateuszdebinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?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\Core\Repository\Events\Content; | ||
|
||
use Ibexa\Contracts\Core\Repository\Event\BeforeEvent; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||
use UnexpectedValueException; | ||
|
||
final class BeforeLoadContentEvent extends BeforeEvent | ||
{ | ||
private int $contentId; | ||
|
||
/** @var string[]|null */ | ||
private ?array $languages; | ||
|
||
private ?int $versionNo; | ||
|
||
private bool $useAlwaysAvailable; | ||
|
||
private ?Content $content = null; | ||
|
||
/** | ||
* @param string[] $languages | ||
*/ | ||
public function __construct( | ||
int $contentId, | ||
array $languages = null, | ||
?int $versionNo = null, | ||
bool $useAlwaysAvailable = true | ||
) { | ||
$this->contentId = $contentId; | ||
$this->languages = $languages; | ||
$this->versionNo = $versionNo; | ||
$this->useAlwaysAvailable = $useAlwaysAvailable; | ||
} | ||
|
||
public function getContentId(): int | ||
{ | ||
return $this->contentId; | ||
} | ||
|
||
/** | ||
* @return string[]|null | ||
*/ | ||
public function getLanguages(): ?array | ||
{ | ||
return $this->languages; | ||
} | ||
|
||
public function getVersionNo(): ?int | ||
{ | ||
return $this->versionNo; | ||
} | ||
|
||
public function getUseAlwaysAvailable(): bool | ||
{ | ||
return $this->useAlwaysAvailable; | ||
} | ||
|
||
public function getContent(): Content | ||
{ | ||
if (!$this->hasContent()) { | ||
throw new UnexpectedValueException( | ||
sprintf( | ||
'Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', | ||
Content::class | ||
) | ||
); | ||
} | ||
|
||
return $this->content; | ||
} | ||
|
||
public function setContent(?Content $content): void | ||
{ | ||
$this->content = $content; | ||
} | ||
|
||
/** @phpstan-assert-if-true !null $this->content */ | ||
public function hasContent(): bool | ||
{ | ||
return $this->content instanceof Content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling this is here on purpose so you won't forget to implement a pair of events - before event and event.
Any POV @Nattfarinn or @ibexa/php-dev?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add the after event for the loadContent function here, but I will add it if necessary :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say event layer is complete only if it dispatches Before and After events. Before for pipeline interception and input refinement, After as a reaction and postprocessing.
I would add After event. Thanks @alongosz for catching this 👍 .