Skip to content

IBX-13242: Remove realtime editing from dev doc - #3485

Draft
dabrt wants to merge 2 commits into
4.6from
IBX-13242
Draft

dabrt wants to merge 2 commits into
4.6from
IBX-13242

Conversation

@dabrt

@dabrt dabrt commented Nov 19, 2026

Copy link
Copy Markdown
Contributor
Question Answer
JIRA Ticket IBX-13242
Versions 4.6 and up
Edition all

Remove realtime editing from dev doc

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages

@github-actions

Copy link
Copy Markdown

code_samples/ change report

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

code_samples/collaboration/src/Command/ManageSessionsCommand.php


code_samples/collaboration/src/Command/ManageSessionsCommand.php

docs/content_management/collaborative_editing/collaborative_editing_api.md@22:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@23:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 63, 74) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@24:```
docs/content_management/content_sharing/content_sharing_api.md@22:``` php
docs/content_management/content_sharing/content_sharing_api.md@23:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 63, 74) =]]
docs/content_management/content_sharing/content_sharing_api.md@24:```

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();


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@32:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@33:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 76, 77) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@34:```
docs/content_management/content_sharing/content_sharing_api.md@32:``` php
docs/content_management/content_sharing/content_sharing_api.md@33:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 76, 77) =]]
docs/content_management/content_sharing/content_sharing_api.md@34:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@38:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@39:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 77, 78) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@40:```
docs/content_management/content_sharing/content_sharing_api.md@38:``` php
docs/content_management/content_sharing/content_sharing_api.md@39:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 77, 78) =]]
docs/content_management/content_sharing/content_sharing_api.md@40:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@46:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@47:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 80, 82) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@48:```
docs/content_management/content_sharing/content_sharing_api.md@46:``` php
docs/content_management/content_sharing/content_sharing_api.md@47:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 80, 82) =]]
docs/content_management/content_sharing/content_sharing_api.md@48:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@56:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@57:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 84, 88) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@58:```
docs/content_management/content_sharing/content_sharing_api.md@56:``` php
docs/content_management/content_sharing/content_sharing_api.md@57:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 84, 88) =]]
docs/content_management/content_sharing/content_sharing_api.md@58:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@64:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@65:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 163, 164) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@66:```
docs/content_management/content_sharing/content_sharing_api.md@64:``` php
docs/content_management/content_sharing/content_sharing_api.md@65:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 163, 164) =]]
docs/content_management/content_sharing/content_sharing_api.md@66:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@74:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@75:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 96, 109) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@76:```
docs/content_management/content_sharing/content_sharing_api.md@74:``` php
docs/content_management/content_sharing/content_sharing_api.md@75:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 96, 109) =]]
docs/content_management/content_sharing/content_sharing_api.md@76:```

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);


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@93:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@94:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 111, 118) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@95:```
docs/content_management/content_sharing/content_sharing_api.md@96:``` php
docs/content_management/content_sharing/content_sharing_api.md@97:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 111, 118) =]]
docs/content_management/content_sharing/content_sharing_api.md@98:```

001⫶ $participant = $this->sessionService
002⫶ ->getSession($session->getId())
003⫶ ->getParticipants()
004⫶ ->getByEmail($user->email);
005⫶

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

007⫶        $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@100:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@101:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 120, 121) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@102:```
docs/content_management/content_sharing/content_sharing_api.md@104:``` php
docs/content_management/content_sharing/content_sharing_api.md@105:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 120, 121) =]]
docs/content_management/content_sharing/content_sharing_api.md@106:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@108:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@109:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 123, 127) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@110:```
docs/content_management/content_sharing/content_sharing_api.md@112:``` php
docs/content_management/content_sharing/content_sharing_api.md@113:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 123, 127) =]]
docs/content_management/content_sharing/content_sharing_api.md@114:```

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


001⫶ $this->sessionService->isSessionOwner(
002⫶ $session,
003⫶ $this->userService->loadUserByLogin('another_user')
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', 129, 133) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@120:```
docs/content_management/content_sharing/content_sharing_api.md@122:``` php
docs/content_management/content_sharing/content_sharing_api.md@123:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 129, 133) =]]
docs/content_management/content_sharing/content_sharing_api.md@124:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@129:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@130:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 142, 143) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@131:```
docs/content_management/content_sharing/content_sharing_api.md@133:``` php
docs/content_management/content_sharing/content_sharing_api.md@134:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 142, 143) =]]
docs/content_management/content_sharing/content_sharing_api.md@135:```

001⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);


001⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@137:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@138:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 145, 151) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@139:```
docs/content_management/content_sharing/content_sharing_api.md@141:``` php
docs/content_management/content_sharing/content_sharing_api.md@142:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 145, 151) =]]
docs/content_management/content_sharing/content_sharing_api.md@143:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@147:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@148:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 153, 157) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@149:```
docs/content_management/content_sharing/content_sharing_api.md@151:``` php
docs/content_management/content_sharing/content_sharing_api.md@152:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 153, 157) =]]
docs/content_management/content_sharing/content_sharing_api.md@153:```

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


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@155:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@156:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 159, 161) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@157:```
docs/content_management/content_sharing/content_sharing_api.md@159:``` php
docs/content_management/content_sharing/content_sharing_api.md@160:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 159, 161) =]]
docs/content_management/content_sharing/content_sharing_api.md@161:```

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


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

docs/content_management/collaborative_editing/collaborative_editing_api.md@163:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@164:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 135, 141) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@165:```
docs/content_management/content_sharing/content_sharing_api.md@167:``` php
docs/content_management/content_sharing/content_sharing_api.md@168:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 135, 141) =]]
docs/content_management/content_sharing/content_sharing_api.md@169:```

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⫶ }


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⫶ }

docs/content_management/collaborative_editing/collaborative_editing_api.md@173:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@174:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php') =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@175:```
docs/content_management/content_sharing/content_sharing_api.md@177:``` php
docs/content_management/content_sharing/content_sharing_api.md@178:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php') =]]
docs/content_management/content_sharing/content_sharing_api.md@179:```

001⫶<?php declare(strict_types=1);
002⫶
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\Command\Command;
024⫶use Symfony\Component\Console\Input\InputInterface;
025⫶use Symfony\Component\Console\Output\OutputInterface;
026⫶
027⫶final class ManageSessionsCommand extends Command
028⫶{
029⫶ protected static $defaultName = 'app:manage-sessions';
030⫶
031⫶ private InvitationServiceInterface $invitationService;
032⫶
033⫶ private SessionServiceInterface $sessionService;
034⫶
035⫶ private ContentService $contentService;
036⫶
037⫶ private UserService $userService;
038⫶
039⫶ private PermissionResolver $permissionResolver;
040⫶
041⫶ public function __construct(
042⫶ InvitationServiceInterface $invitationService,
043⫶ SessionServiceInterface $sessionService,
044⫶ ContentService $contentService,
045⫶ UserService $userService,
046⫶ PermissionResolver $permissionResolver
047⫶ ) {
048⫶ parent::__construct(self::$defaultName);
049⫶
050⫶ $this->invitationService = $invitationService;
051⫶ $this->sessionService = $sessionService;
052⫶ $this->contentService = $contentService;
053⫶ $this->userService = $userService;
054⫶ $this->permissionResolver = $permissionResolver;
055⫶ }
056⫶
057⫶ public function execute(InputInterface $input, OutputInterface $output): int
058⫶ {
059⫶ $this->permissionResolver->setCurrentUserReference(
060⫶ $this->userService->loadUserByLogin('admin')
061⫶ );
062⫶
063⫶ // Create a sharing session for Content
064⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
065⫶ $createStruct = new ContentSessionCreateStruct(
066⫶ $versionInfo,
067⫶ $versionInfo->getInitialLanguage()
068⫶ );
069⫶ $createStruct->setHasPublicLink(false);
070⫶
071⫶ $token = 'my-secret-token-12345';
072⫶ $createStruct->setToken($token);
073⫶
074⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();
075⫶
076⫶ // Get a session by ID or token
077⫶ $session = $this->sessionService->getSession($sessionId);
078⫶ $session = $this->sessionService->getSessionByToken($token);
079⫶
080⫶ // Find sessions
081⫶ $sessionQuery = new SessionQuery(new Token($token));
082⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();
083⫶
084⫶ // Update a session
085⫶ $updateStruct = new ContentSessionUpdateStruct();
086⫶ $updateStruct->setHasPublicLink(true);
087⫶
088⫶ $this->sessionService->updateSession($session, $updateStruct);
089⫶
090⫶ // Deactivate a session
091⫶ $updateStruct = new ContentSessionUpdateStruct();
092⫶ $updateStruct->setIsActive(false);
093⫶
094⫶ $this->sessionService->updateSession($session, $updateStruct);
095⫶
096⫶ // Manage participants
097⫶ $user = $this->userService->loadUserByLogin('another_user');
098⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
099⫶ $user,
100⫶ ContentSessionScope::VIEW
101⫶ );
102⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
103⫶ 'external@example.com',
104⫶ ContentSessionScope::VIEW,
105⫶ 'personal-secret-token-12345'
106⫶ );
107⫶
108⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
109⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);
110⫶
111⫶ // Get and update participants
112⫶ $participant = $this->sessionService
113⫶ ->getSession($session->getId())
114⫶ ->getParticipants()
115⫶ ->getByEmail($user->email);
116⫶

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

118⫶        $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);
119⫶
120⫶ // Remove participant
121⫶ $this->sessionService->removeParticipant($session, $externalParticipant);
122⫶
123⫶ // Check ownerships. If no user is provided, current user is used.
124⫶ $this->sessionService->isSessionOwner(
125⫶ $session,
126⫶ $this->userService->loadUserByLogin('another_user')
127⫶ );
128⫶
129⫶ // Check participation
130⫶ $this->sessionService->isSessionParticipant(
131⫶ $session,
132⫶ $this->permissionResolver->getCurrentUserReference()
133⫶ );
134⫶
135⫶ // Manage invitations
136⫶ $invitationQuery = new InvitationQuery(new Session($session));
137⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
138⫶
139⫶ foreach ($invitations as $invitation) {
140⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
141⫶ }
142⫶
143⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);
144⫶
145⫶ // Create invitation - use when auto-inviting participants is not enabled
146⫶ $invitationCreateStruct = new InvitationCreateStruct(
147⫶ $session,
148⫶ $internalParticipant
149⫶ );
150⫶
151⫶ $this->invitationService->createInvitation($invitationCreateStruct);
152⫶
153⫶ // Update invitation
154⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
155⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
156⫶
157⫶ $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);
158⫶
159⫶ // Delete invitation
160⫶ $invitation = $this->invitationService->getInvitation(2);
161⫶ $this->invitationService->deleteInvitation($invitation);
162⫶
163⫶ // Delete a session
164⫶ $this->sessionService->deleteSession($session);
165⫶
166⫶ return Command::SUCCESS;
167⫶ }
168⫶}

Download colorized diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant