Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
topicmanager.php
1<?php
2namespace Bitrix\Forum\Copy;
3
4use Bitrix\Forum\Copy\Implement\Comment as CommentImplementer;
5use Bitrix\Forum\Copy\Implement\Topic as TopicImplementer;
9
11{
12 private $executiveUserId;
13 private $topicIdsToCopy = [];
14
15 public function __construct($executiveUserId, array $topicIdsToCopy)
16 {
17 $this->executiveUserId = $executiveUserId;
18 $this->topicIdsToCopy = $topicIdsToCopy;
19 }
20
21 public function startCopy()
22 {
23 $containerCollection = $this->getContainerCollection();
24
25 $topicCopier = $this->getTopicCopier();
26
27 return $topicCopier->copy($containerCollection);
28 }
29
30 private function getContainerCollection()
31 {
32 $containerCollection = new ContainerCollection();
33
34 foreach ($this->topicIdsToCopy as $topicId)
35 {
36 $containerCollection[] = new Container($topicId);
37 }
38
39 return $containerCollection;
40 }
41
42 private function getTopicCopier()
43 {
44 return new EntityCopier($this->getTopicImplementer());
45 }
46
47 private function getTopicImplementer()
48 {
49 global $USER_FIELD_MANAGER;
50
51 $commentImplementer = new CommentImplementer();
52 $commentImplementer->setUserFieldManager($USER_FIELD_MANAGER);
53 $commentImplementer->setExecutiveUserId($this->executiveUserId);
54 $commentCopier = new EntityCopier($commentImplementer);
55
56 $topicImplementer = new TopicImplementer();
57 $topicImplementer->setCommentCopier($commentCopier);
58
59 return $topicImplementer;
60 }
61}
__construct($executiveUserId, array $topicIdsToCopy)