Skip to content

Removed copyright from code samples - #3077

Merged
mnocon merged 1 commit into
5.0from
remove-copyright
Mar 9, 2026
Merged

mnocon merged 1 commit into
5.0from
remove-copyright

Conversation

@mnocon

@mnocon mnocon commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Target: v4.6 and 5.0

Removed copyright from code samples

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Mar 6, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown

code_samples/ change report

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

code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php

docs/pim/create_custom_attribute_type.md@165:``` php
docs/pim/create_custom_attribute_type.md@166:[[= include_file('code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php') =]]
docs/pim/create_custom_attribute_type.md@167:```


code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php

docs/pim/create_custom_attribute_type.md@165:``` php
docs/pim/create_custom_attribute_type.md@166:[[= include_file('code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php') =]]
docs/pim/create_custom_attribute_type.md@167:```

001⫶<?php
001⫶<?php declare(strict_types=1);
002⫶
002⫶
003⫶/**
004⫶ * @copyright Copyright (C) Ibexa AS. All rights reserved.
005⫶ * @license For full copyright and license information view LICENSE file distributed with this source code.
006⫶ */
007⫶declare(strict_types=1);
008⫶
009⫶namespace App\Attribute\Percent\Storage;
010⫶
011⫶use Doctrine\DBAL\Types\Types;
012⫶use Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface;
013⫶
014⫶final class PercentStorageDefinition implements StorageDefinitionInterface
015⫶{
016⫶ public function getColumns(): array
017⫶ {
018⫶ return [
019⫶ 'value' => Types::FLOAT,
020⫶ ];
021⫶ }
022⫶
023⫶ public function getTableName(): string
024⫶ {
025⫶ return 'app_product_specification_attribute_percent';
026⫶ }
027⫶}
003⫶namespace App\Attribute\Percent\Storage;
004⫶
005⫶use Doctrine\DBAL\Types\Types;
006⫶use Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface;
007⫶
008⫶final class PercentStorageDefinition implements StorageDefinitionInterface
009⫶{
010⫶ public function getColumns(): array
011⫶ {
012⫶ return [
013⫶ 'value' => Types::FLOAT,
014⫶ ];
015⫶ }
016⫶
017⫶ public function getTableName(): string
018⫶ {
019⫶ return 'app_product_specification_attribute_percent';
020⫶ }
021⫶}


code_samples/cdp/date_of_birth_export/src/Export/User/DateOfBirthUserItemProcessor.php

docs/cdp/cdp_data_customization.md@22:``` php
docs/cdp/cdp_data_customization.md@23:[[= include_file('code_samples/cdp/date_of_birth_export/src/Export/User/DateOfBirthUserItemProcessor.php') =]]
docs/cdp/cdp_data_customization.md@24:```



code_samples/cdp/date_of_birth_export/src/Export/User/DateOfBirthUserItemProcessor.php

docs/cdp/cdp_data_customization.md@22:``` php
docs/cdp/cdp_data_customization.md@23:[[= include_file('code_samples/cdp/date_of_birth_export/src/Export/User/DateOfBirthUserItemProcessor.php') =]]
docs/cdp/cdp_data_customization.md@24:```

001⫶<?php
001⫶<?php declare(strict_types=1);
002⫶
002⫶
003⫶/**
004⫶ * @copyright Copyright (C) Ibexa AS. All rights reserved.
005⫶ * @license For full copyright and license information view LICENSE file distributed with this source code.
006⫶ */
007⫶declare(strict_types=1);
008⫶
009⫶namespace App\Export\User;
010⫶
011⫶use Ibexa\Contracts\Cdp\Export\User\AbstractUserItemProcessor;
012⫶use Ibexa\Contracts\Core\Repository\Values\Content\Content;
013⫶use Ibexa\Core\FieldType\Date\Value as DateValue;
014⫶use InvalidArgumentException;
015⫶
016⫶final class DateOfBirthUserItemProcessor extends AbstractUserItemProcessor
017⫶{
018⫶ public function __construct(
019⫶ private readonly string $dateOfBirthFieldIdentifier,
020⫶ string $userFieldTypeIdentifier
021⫶ ) {
022⫶ parent::__construct($userFieldTypeIdentifier);
023⫶ }
024⫶
025⫶ protected function doProcess(array $processedItemData, Content $userContent): array
026⫶ {
027⫶ $userField = $this->getUserField($userContent);
028⫶
029⫶ if (null === $userField) {
030⫶ throw new InvalidArgumentException('Content does not contain user field');
031⫶ }
032⫶
033⫶ $dateOfBirth = '';
034⫶ $dateOfBirthField = $userContent->getField($this->dateOfBirthFieldIdentifier);
035⫶
036⫶ if ($dateOfBirthField !== null
037⫶ && $dateOfBirthField->value instanceof DateValue
038⫶ && $dateOfBirthField->value->date !== null
039⫶ ) {
040⫶ $dateOfBirth = $dateOfBirthField->value->date->format('Y-m-d');
041⫶ }
042⫶
043⫶ return array_merge(
044⫶ $processedItemData,
045⫶ [
046⫶ 'date_of_birth' => $dateOfBirth,
047⫶ ]
048⫶ );
049⫶ }
050⫶}
003⫶namespace App\Export\User;
004⫶
005⫶use Ibexa\Contracts\Cdp\Export\User\AbstractUserItemProcessor;
006⫶use Ibexa\Contracts\Core\Repository\Values\Content\Content;
007⫶use Ibexa\Core\FieldType\Date\Value as DateValue;
008⫶use InvalidArgumentException;
009⫶
010⫶final class DateOfBirthUserItemProcessor extends AbstractUserItemProcessor
011⫶{
012⫶ public function __construct(
013⫶ private readonly string $dateOfBirthFieldIdentifier,
014⫶ string $userFieldTypeIdentifier
015⫶ ) {
016⫶ parent::__construct($userFieldTypeIdentifier);
017⫶ }
018⫶
019⫶ protected function doProcess(array $processedItemData, Content $userContent): array
020⫶ {
021⫶ $userField = $this->getUserField($userContent);
022⫶
023⫶ if (null === $userField) {
024⫶ throw new InvalidArgumentException('Content does not contain user field');
025⫶ }
026⫶
027⫶ $dateOfBirth = '';
028⫶ $dateOfBirthField = $userContent->getField($this->dateOfBirthFieldIdentifier);
029⫶
030⫶ if ($dateOfBirthField !== null
031⫶ && $dateOfBirthField->value instanceof DateValue
032⫶ && $dateOfBirthField->value->date !== null
033⫶ ) {
034⫶ $dateOfBirth = $dateOfBirthField->value->date->format('Y-m-d');
035⫶ }
036⫶
037⫶ return array_merge(
038⫶ $processedItemData,
039⫶ [
040⫶ 'date_of_birth' => $dateOfBirth,
041⫶ ]
042⫶ );
043⫶ }
044⫶}


code_samples/collaboration/src/Command/ManageSessionsCommand.php

docs/content_management/collaborative_editing/collaborative_editing_api.md@19:``` php


code_samples/collaboration/src/Command/ManageSessionsCommand.php

docs/content_management/collaborative_editing/collaborative_editing_api.md@19:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@20:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 53, 65) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@20:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 47, 58) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@21:```

001⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
002⫶ $createStruct = new ContentSessionCreateStruct(
003⫶ $versionInfo,
004⫶ $versionInfo->getInitialLanguage()
005⫶ );
006⫶ $createStruct->setHasPublicLink(false);
007⫶
008⫶ $token = 'my-secret-token-12345';
009⫶ $createStruct->setToken($token);
010⫶
011⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();

docs/content_management/collaborative_editing/collaborative_editing_api.md@29:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@21:```

001⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
002⫶ $createStruct = new ContentSessionCreateStruct(
003⫶ $versionInfo,
004⫶ $versionInfo->getInitialLanguage()
005⫶ );
006⫶ $createStruct->setHasPublicLink(false);
007⫶
008⫶ $token = 'my-secret-token-12345';
009⫶ $createStruct->setToken($token);
010⫶
011⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();

docs/content_management/collaborative_editing/collaborative_editing_api.md@29:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@30:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 66, 67) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@30:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 60, 61) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@31:```

001⫶ $session = $this->sessionService->getSession($sessionId);

docs/content_management/collaborative_editing/collaborative_editing_api.md@35:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@31:```

001⫶ $session = $this->sessionService->getSession($sessionId);

docs/content_management/collaborative_editing/collaborative_editing_api.md@35:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@36:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 67, 68) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@36:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 61, 62) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@37:```

001⫶ $session = $this->sessionService->getSessionByToken($token);

docs/content_management/collaborative_editing/collaborative_editing_api.md@43:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@37:```

001⫶ $session = $this->sessionService->getSessionByToken($token);

docs/content_management/collaborative_editing/collaborative_editing_api.md@43:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@44:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 70, 73) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@44:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 64, 66) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@45:```

001⫶ $sessionQuery = new SessionQuery(new Token($token));
002⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();

docs/content_management/collaborative_editing/collaborative_editing_api.md@53:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@45:```

001⫶ $sessionQuery = new SessionQuery(new Token($token));
002⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();

docs/content_management/collaborative_editing/collaborative_editing_api.md@53:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@54:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 74, 79) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@54:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 68, 72) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@55:```

001⫶ $updateStruct = new ContentSessionUpdateStruct();
002⫶ $updateStruct->setHasPublicLink(true);
003⫶
004⫶ $this->sessionService->updateSession($session, $updateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@61:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@55:```

001⫶ $updateStruct = new ContentSessionUpdateStruct();
002⫶ $updateStruct->setHasPublicLink(true);
003⫶
004⫶ $this->sessionService->updateSession($session, $updateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@61:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@62:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 153, 154) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@62:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 147, 148) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@63:```

001⫶ $this->sessionService->deleteSession($session);

docs/content_management/collaborative_editing/collaborative_editing_api.md@71:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@63:```

001⫶ $this->sessionService->deleteSession($session);

docs/content_management/collaborative_editing/collaborative_editing_api.md@71:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@72:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 86, 100) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@72:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 80, 93) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@73:```

001⫶ $user = $this->userService->loadUserByLogin('another_user');
002⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
003⫶ $user,
004⫶ ContentSessionScope::VIEW
005⫶ );
006⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
007⫶ 'external@example.com',
008⫶ ContentSessionScope::VIEW,
009⫶ 'personal-secret-token-12345'
010⫶ );
011⫶
012⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
013⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@79:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@73:```

001⫶ $user = $this->userService->loadUserByLogin('another_user');
002⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
003⫶ $user,
004⫶ ContentSessionScope::VIEW
005⫶ );
006⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
007⫶ 'external@example.com',
008⫶ ContentSessionScope::VIEW,
009⫶ 'personal-secret-token-12345'
010⫶ );
011⫶
012⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
013⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@79:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@80:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 101, 109) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@80:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 95, 102) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@81:```

001⫶ $participant = $this->sessionService
002⫶ ->getSession($session->getId())
003⫶ ->getParticipants()
004⫶ ->getByEmail($user->email);
005⫶
006⫶ $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
007⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@89:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@81:```

001⫶ $participant = $this->sessionService
002⫶ ->getSession($session->getId())
003⫶ ->getParticipants()
004⫶ ->getByEmail($user->email);
005⫶
006⫶ $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
007⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@89:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@90:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 110, 111) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@90:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 104, 105) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@91:```

001⫶ $this->sessionService->removeParticipant($session, $externalParticipant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@97:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@91:```

001⫶ $this->sessionService->removeParticipant($session, $externalParticipant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@97:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@98:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 113, 118) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@98:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 107, 111) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@99:```

001⫶ $this->sessionService->isSessionOwner(
002⫶ $session,
003⫶ $this->userService->loadUserByLogin('another_user')
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@107:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@99:```

001⫶ $this->sessionService->isSessionOwner(
002⫶ $session,
003⫶ $this->userService->loadUserByLogin('another_user')
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@107:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@108:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 119, 124) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@108:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 113, 117) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@109:```

001⫶ $this->sessionService->isSessionParticipant(
002⫶ $session,
003⫶ $this->permissionResolver->getCurrentUserReference()
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@118:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@109:```

001⫶ $this->sessionService->isSessionParticipant(
002⫶ $session,
003⫶ $this->permissionResolver->getCurrentUserReference()
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@118:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@119:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 125, 134) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@119:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 119, 127) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@120:```

001⫶ $invitationQuery = new InvitationQuery(new Session($session));
002⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
003⫶
004⫶ foreach ($invitations as $invitation) {
005⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
006⫶ }
007⫶
008⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@126:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@120:```

001⫶ $invitationQuery = new InvitationQuery(new Session($session));
002⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
003⫶
004⫶ foreach ($invitations as $invitation) {
005⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
006⫶ }
007⫶
008⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@126:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@127:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 135, 142) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@127:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 129, 135) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@128:```

001⫶ $invitationCreateStruct = new InvitationCreateStruct(
002⫶ $session,
003⫶ $internalParticipant
004⫶ );
005⫶
006⫶ $this->invitationService->createInvitation($invitationCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@136:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@128:```

001⫶ $invitationCreateStruct = new InvitationCreateStruct(
002⫶ $session,
003⫶ $internalParticipant
004⫶ );
005⫶
006⫶ $this->invitationService->createInvitation($invitationCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@136:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@137:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 143, 148) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@137:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 137, 141) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@138:```

001⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
002⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
003⫶
004⫶ $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@144:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@138:```

001⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
002⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
003⫶
004⫶ $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@144:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@145:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 149, 152) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@145:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 143, 145) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@146:```

001⫶ $invitation = $this->invitationService->getInvitation(2);
002⫶ $this->invitationService->deleteInvitation($invitation);

docs/content_management/collaborative_editing/collaborative_editing_api.md@158:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@159:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php') =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@160:```

docs/content_management/collaborative_editing/collaborative_editing_api.md@146:```

001⫶ $invitation = $this->invitationService->getInvitation(2);
002⫶ $this->invitationService->deleteInvitation($invitation);

docs/content_management/collaborative_editing/collaborative_editing_api.md@158:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@159:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php') =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@160:```

001⫶<?php
001⫶<?php declare(strict_types=1);
002⫶
002⫶
003⫶/**
004⫶ * @copyright Copyright (C) Ibexa AS. All rights reserved.
005⫶ * @license For full copyright and license information view LICENSE file distributed with this source code.
006⫶ */
007⫶declare(strict_types=1);
008⫶
009⫶namespace App\Command;
010⫶
011⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationCreateStruct;
012⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationQuery;
013⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationStatus;
014⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationUpdateStruct;
015⫶use Ibexa\Contracts\Collaboration\Invitation\Query\Criterion\Session;
016⫶use Ibexa\Contracts\Collaboration\InvitationServiceInterface;
017⫶use Ibexa\Contracts\Collaboration\Participant\ExternalParticipantCreateStruct;
018⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantCreateStruct;
019⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantUpdateStruct;
020⫶use Ibexa\Contracts\Collaboration\Session\Query\Criterion\Token;
021⫶use Ibexa\Contracts\Collaboration\Session\SessionQuery;
022⫶use Ibexa\Contracts\Collaboration\SessionServiceInterface;
023⫶use Ibexa\Contracts\Core\Repository\ContentService;
024⫶use Ibexa\Contracts\Core\Repository\PermissionResolver;
025⫶use Ibexa\Contracts\Core\Repository\UserService;
026⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionCreateStruct;
027⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionScope;
028⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionUpdateStruct;
029⫶use Symfony\Component\Console\Attribute\AsCommand;
030⫶use Symfony\Component\Console\Command\Command;
031⫶use Symfony\Component\Console\Input\InputInterface;
032⫶use Symfony\Component\Console\Output\OutputInterface;
033⫶
034⫶#[AsCommand(name: 'app:manage-sessions')]
035⫶final class ManageSessionsCommand extends Command
036⫶{
037⫶ public function __construct(
038⫶ private readonly InvitationServiceInterface $invitationService,
039⫶ private readonly SessionServiceInterface $sessionService,
040⫶ private readonly ContentService $contentService,
041⫶ private readonly UserService $userService,
042⫶ private readonly PermissionResolver $permissionResolver
043⫶ ) {
044⫶ parent::__construct();
045⫶ }
003⫶namespace App\Command;
004⫶
005⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationCreateStruct;
006⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationQuery;
007⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationStatus;
008⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationUpdateStruct;
009⫶use Ibexa\Contracts\Collaboration\Invitation\Query\Criterion\Session;
010⫶use Ibexa\Contracts\Collaboration\InvitationServiceInterface;
011⫶use Ibexa\Contracts\Collaboration\Participant\ExternalParticipantCreateStruct;
012⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantCreateStruct;
013⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantUpdateStruct;
014⫶use Ibexa\Contracts\Collaboration\Session\Query\Criterion\Token;
015⫶use Ibexa\Contracts\Collaboration\Session\SessionQuery;
016⫶use Ibexa\Contracts\Collaboration\SessionServiceInterface;
017⫶use Ibexa\Contracts\Core\Repository\ContentService;
018⫶use Ibexa\Contracts\Core\Repository\PermissionResolver;
019⫶use Ibexa\Contracts\Core\Repository\UserService;
020⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionCreateStruct;
021⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionScope;
022⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionUpdateStruct;
023⫶use Symfony\Component\Console\Attribute\AsCommand;
024⫶use Symfony\Component\Console\Command\Command;
025⫶use Symfony\Component\Console\Input\InputInterface;
026⫶use Symfony\Component\Console\Output\OutputInterface;
027⫶
028⫶#[AsCommand(name: 'app:manage-sessions')]
029⫶final class ManageSessionsCommand extends Command
030⫶{
031⫶ public function __construct(
032⫶ private readonly InvitationServiceInterface $invitationService,
033⫶ private readonly SessionServiceInterface $sessionService,
034⫶ private readonly ContentService $contentService,
035⫶ private readonly UserService $userService,
036⫶ private readonly PermissionResolver $permissionResolver
037⫶ ) {
038⫶ parent::__construct();
039⫶ }
040⫶
041⫶ public function execute(InputInterface $input, OutputInterface $output): int
042⫶ {
043⫶ $this->permissionResolver->setCurrentUserReference(
044⫶ $this->userService->loadUserByLogin('admin')
045⫶ );
046⫶
046⫶
047⫶    public function execute(InputInterface $input, OutputInterface $output): int
048⫶ {
049⫶ $this->permissionResolver->setCurrentUserReference(
050⫶ $this->userService->loadUserByLogin('admin')
051⫶ );
052⫶
053⫶ // Create a sharing session for Content
054⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
055⫶ $createStruct = new ContentSessionCreateStruct(
056⫶ $versionInfo,
057⫶ $versionInfo->getInitialLanguage()
058⫶ );
059⫶ $createStruct->setHasPublicLink(false);
060⫶
061⫶ $token = 'my-secret-token-12345';
062⫶ $createStruct->setToken($token);
047⫶        // Create a sharing session for Content
048⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
049⫶ $createStruct = new ContentSessionCreateStruct(
050⫶ $versionInfo,
051⫶ $versionInfo->getInitialLanguage()
052⫶ );
053⫶ $createStruct->setHasPublicLink(false);
054⫶
055⫶ $token = 'my-secret-token-12345';
056⫶ $createStruct->setToken($token);
057⫶
058⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();
059⫶
060⫶ // Get a session by ID or token
061⫶ $session = $this->sessionService->getSession($sessionId);
062⫶ $session = $this->sessionService->getSessionByToken($token);
063⫶
063⫶
064⫶        $sessionId = $this->sessionService->createSession($createStruct)->getId();
065⫶
066⫶ // Get a session by ID or token
067⫶ $session = $this->sessionService->getSession($sessionId);
068⫶ $session = $this->sessionService->getSessionByToken($token);
069⫶
070⫶ // Find sessions
071⫶ $sessionQuery = new SessionQuery(new Token($token));
072⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();
064⫶        // Find sessions
065⫶ $sessionQuery = new SessionQuery(new Token($token));
066⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();
067⫶
068⫶ // Update a session
069⫶ $updateStruct = new ContentSessionUpdateStruct();
070⫶ $updateStruct->setHasPublicLink(true);
071⫶
072⫶ $this->sessionService->updateSession($session, $updateStruct);
073⫶
073⫶
074⫶        // Update a session
074⫶        // Deactivate a session
075⫶        $updateStruct = new ContentSessionUpdateStruct();
075⫶        $updateStruct = new ContentSessionUpdateStruct();
076⫶        $updateStruct->setHasPublicLink(true);
076⫶        $updateStruct->setIsActive(false);
077⫶
078⫶ $this->sessionService->updateSession($session, $updateStruct);
079⫶
077⫶
078⫶ $this->sessionService->updateSession($session, $updateStruct);
079⫶
080⫶        // Deactivate a session
081⫶ $updateStruct = new ContentSessionUpdateStruct();
082⫶ $updateStruct->setIsActive(false);
083⫶
084⫶ $this->sessionService->updateSession($session, $updateStruct);
085⫶
086⫶ // Manage participants
087⫶ $user = $this->userService->loadUserByLogin('another_user');
088⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
089⫶ $user,
090⫶ ContentSessionScope::VIEW
091⫶ );
092⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
093⫶ 'external@example.com',
094⫶ ContentSessionScope::VIEW,
095⫶ 'personal-secret-token-12345'
096⫶ );
097⫶
098⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
099⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);
080⫶        // Manage participants
081⫶ $user = $this->userService->loadUserByLogin('another_user');
082⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
083⫶ $user,
084⫶ ContentSessionScope::VIEW
085⫶ );
086⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
087⫶ 'external@example.com',
088⫶ ContentSessionScope::VIEW,
089⫶ 'personal-secret-token-12345'
090⫶ );
091⫶
092⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
093⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);
094⫶
095⫶ // Get and update participants
096⫶ $participant = $this->sessionService
097⫶ ->getSession($session->getId())
098⫶ ->getParticipants()
099⫶ ->getByEmail($user->email);
100⫶
100⫶
101⫶        // Get and update participants
102⫶ $participant = $this->sessionService
103⫶ ->getSession($session->getId())
104⫶ ->getParticipants()
105⫶ ->getByEmail($user->email);
101⫶        $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
102⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);
103⫶
104⫶ // Remove participant
105⫶ $this->sessionService->removeParticipant($session, $externalParticipant);
106⫶
106⫶
107⫶        $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
108⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);
109⫶
110⫶ // Remove participant
111⫶ $this->sessionService->removeParticipant($session, $externalParticipant);
107⫶        // Check ownerships. If no user is provided, current user is used.
108⫶ $this->sessionService->isSessionOwner(
109⫶ $session,
110⫶ $this->userService->loadUserByLogin('another_user')
111⫶ );
112⫶
112⫶
113⫶        // Check ownerships. If no user is provided, current user is used.
114⫶ $this->sessionService->isSessionOwner(
113⫶        // Check participation
114⫶ $this->sessionService->isSessionParticipant(
115⫶            $session,
115⫶            $session,
116⫶            $this->userService->loadUserByLogin('another_user')
116⫶            $this->permissionResolver->getCurrentUserReference()
117⫶        );
118⫶
117⫶        );
118⫶
119⫶        // Check participation
120⫶ $this->sessionService->isSessionParticipant(
121⫶ $session,
122⫶ $this->permissionResolver->getCurrentUserReference()
123⫶ );
124⫶
125⫶ // Manage invitations
126⫶ $invitationQuery = new InvitationQuery(new Session($session));
127⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
119⫶        // Manage invitations
120⫶ $invitationQuery = new InvitationQuery(new Session($session));
121⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
122⫶
123⫶ foreach ($invitations as $invitation) {
124⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
125⫶ }
126⫶
127⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);
128⫶
128⫶
129⫶        foreach ($invitations as $invitation) {
130⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
131⫶ }
132⫶
133⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);
129⫶        // Create invitation - use when auto-inviting participants is not enabled
130⫶ $invitationCreateStruct = new InvitationCreateStruct(
131⫶ $session,
132⫶ $internalParticipant
133⫶ );
134⫶
134⫶
135⫶        // Create invitation - use when auto-inviting participants is not enabled
136⫶ $invitationCreateStruct = new InvitationCreateStruct(
137⫶ $session,
138⫶ $internalParticipant
139⫶ );
135⫶        $this->invitationService->createInvitation($invitationCreateStruct);
136⫶
137⫶ // Update invitation
138⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
139⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
140⫶
140⫶
141⫶        $this->invitationService->createInvitation($invitationCreateStruct);
141⫶        $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);
142⫶
142⫶
143⫶        // Update invitation
144⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
145⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
143⫶        // Delete invitation
144⫶ $invitation = $this->invitationService->getInvitation(2);
145⫶ $this->invitationService->deleteInvitation($invitation);
146⫶
146⫶
147⫶        $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);
148⫶
149⫶ // Delete invitation
150⫶ $invitation = $this->invitationService->getInvitation(2);
151⫶ $this->invitationService->deleteInvitation($invitation);
152⫶
153⫶ // Delete a session
154⫶ $this->sessionService->deleteSession($session);
155⫶
156⫶ return Command::SUCCESS;
157⫶ }
158⫶}
147⫶        // Delete a session
148⫶ $this->sessionService->deleteSession($session);
149⫶
150⫶ return Command::SUCCESS;
151⫶ }
152⫶}


Download colorized diff

@mnocon
mnocon marked this pull request as ready for review March 6, 2026 15:25
@mnocon
mnocon requested a review from adriendupuis March 6, 2026 15:25
@mnocon
mnocon merged commit be15543 into 5.0 Mar 9, 2026
10 checks passed
@mnocon
mnocon deleted the remove-copyright branch March 9, 2026 08:15
mnocon added a commit that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants