Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
manager.php
1<?php
2namespace Bitrix\Vote\Copy;
3
7use Bitrix\Vote\Copy\Implement\Answer as AnswerImplementer;
8use Bitrix\Vote\Copy\Implement\Question as QuestionImplementer;
9use Bitrix\Vote\Copy\Implement\Vote as VoteImplementer;
10
12{
13 private $voteIdsToCopy;
14
15 private $resetVotingResult = true;
16
17 private $markerQuestion = true;
18 private $markerAnswer = true;
19
20 public function __construct(array $voteIdsToCopy)
21 {
22 $this->voteIdsToCopy = $voteIdsToCopy;
23 }
24
25 public function markQuestion($marker)
26 {
27 $this->markerQuestion = (bool) $marker;
28 }
29
30 public function markAnswer($marker)
31 {
32 $this->markerAnswer = (bool) $marker;
33 }
34
35 public function setResetVotingResult(bool $bool): void
36 {
37 $this->resetVotingResult = $bool;
38 }
39
40 public function startCopy()
41 {
42 $containerCollection = $this->getContainerCollection();
43
44 $voteCopier = $this->getVoteCopier();
45
46 return $voteCopier->copy($containerCollection);
47 }
48
49 private function getContainerCollection()
50 {
51 $containerCollection = new ContainerCollection();
52
53 foreach ($this->voteIdsToCopy as $id)
54 {
55 $containerCollection[] = new Container($id);
56 }
57
58 return $containerCollection;
59 }
60
61 private function getVoteCopier()
62 {
63 $voteImplementer = new VoteImplementer();
64 $voteImplementer->setResetVotingResult($this->resetVotingResult);
65 if ($this->markerQuestion)
66 {
67 $voteImplementer->setQuestionCopier($this->getQuestionCopier());
68 }
69 return new EntityCopier($voteImplementer);
70 }
71
72 private function getQuestionCopier()
73 {
74 $questionImplementer = new QuestionImplementer();
75 $questionImplementer->setResetVotingResult($this->resetVotingResult);
76 if ($this->markerAnswer)
77 {
78 $questionImplementer->setAnswerCopier($this->getAnswerCopier());
79 }
80
81 return new EntityCopier($questionImplementer);
82 }
83
84 private function getAnswerCopier()
85 {
86 $answerImplementer = new AnswerImplementer();
87 $answerImplementer->setResetVotingResult($this->resetVotingResult);
88 return new EntityCopier($answerImplementer);
89 }
90}
setResetVotingResult(bool $bool)
Definition manager.php:35
__construct(array $voteIdsToCopy)
Definition manager.php:20