Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
blogpostmanager.php
1<?php
3
4use Bitrix\Blog\Copy\Implement\BlogComment as BlogCommentImplementer;
5use Bitrix\Blog\Copy\Implement\BlogPost as BlogPostImplementer;
10
12{
13 private $executiveUserId;
14 private $blogPostIdsToCopy = [];
15
16 private $features = [];
17 private $changedRights = [];
18
19 private $result;
20 private $mapIdsCopiedPosts = [];
21
22 public function __construct($executiveUserId, array $blogPostIdsToCopy)
23 {
24 $this->executiveUserId = $executiveUserId;
25 $this->blogPostIdsToCopy = $blogPostIdsToCopy;
26
27 $this->result = new Result();
28 }
29
35 public function setFeatures(array $features)
36 {
37 $this->features = array_filter($features);
38 }
39
40 public function setChangedRights($changedRights)
41 {
42 $this->changedRights = $changedRights;
43 }
44
45 public function startCopy()
46 {
47 $containerCollection = $this->getContainerCollection();
48
49 $blogPostImplementer = $this->getBlogPostImplementer();
50 $blogPostCopier = $this->getBlogPostCopier($blogPostImplementer);
51
52 $this->result = $blogPostCopier->copy($containerCollection);
53 $this->mapIdsCopiedPosts = $blogPostCopier->getMapIdsCopiedEntity();
54
55 return $this->result;
56 }
57
58 public function getMapIdsCopiedPosts()
59 {
60 return $this->mapIdsCopiedPosts;
61 }
62
63 private function getContainerCollection()
64 {
65 $containerCollection = new ContainerCollection();
66
67 foreach ($this->blogPostIdsToCopy as $blogPostId)
68 {
69 $containerCollection[] = new Container($blogPostId);
70 }
71
72 return $containerCollection;
73 }
74
75 private function getBlogPostCopier(BlogPostImplementer $blogPostImplementer)
76 {
77 return new EntityCopier($blogPostImplementer);
78 }
79
80 private function getBlogPostImplementer()
81 {
82 global $USER_FIELD_MANAGER;
83
84 $blogPostImplementer = new BlogPostImplementer();
85
86 $blogPostImplementer->setBlogCommentCopier($this->getBlogCommentCopier());
87 $blogPostImplementer->setUserFieldManager($USER_FIELD_MANAGER);
88 $blogPostImplementer->setFeatures($this->features);
89 $blogPostImplementer->setChangedRights($this->changedRights);
90 $blogPostImplementer->setExecutiveUserId($this->executiveUserId);
91
92 return $blogPostImplementer;
93 }
94
95 private function getBlogCommentCopier()
96 {
97 global $USER_FIELD_MANAGER;
98
99 $blogCommentImplementer = new BlogCommentImplementer();
100
101 $blogCommentImplementer->setUserFieldManager($USER_FIELD_MANAGER);
102 $blogCommentImplementer->setExecutiveUserId($this->executiveUserId);
103
104 return new EntityCopier($blogCommentImplementer);
105 }
106}
setChangedRights($changedRights)
__construct($executiveUserId, array $blogPostIdsToCopy)
setFeatures(array $features)
startCopy()
getMapIdsCopiedPosts()
Definition blogpost.php:14