Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
blogcomment.php
1<?php
3
7
8class BlogComment extends Base
9{
10 const BLOG_COMMENT_COPY_ERROR = "BLOG_COMMENT_COPY_ERROR";
11
12 protected $ufEntityObject = "BLOG_COMMENT";
13 protected $ufDiskFileField = "UF_BLOG_COMMENT_FILE";
14
22 public function add(Container $container, array $fields)
23 {
24 $commentId = \CBlogComment::add($fields);
25
26 if (!$commentId)
27 {
28 $this->result->addError(new Error("Blog comment hasn't been added", self::BLOG_COMMENT_COPY_ERROR));
29 }
30
31 return $commentId;
32 }
33
41 public function getFields(Container $container, $entityId)
42 {
43 $queryObject = \CBlogComment::getlist([], ["ID" => $entityId], false, false, ["*"]);
44
45 return (($fields = $queryObject->fetch()) ? $fields : []);
46 }
47
55 public function prepareFieldsToCopy(Container $container, array $fields)
56 {
57 unset($fields["ID"]);
58
59 if ($container->getParentId())
60 {
61 $fields["POST_ID"] = $container->getParentId();
62 }
63
64 return $fields;
65 }
66
75 public function copyChildren(Container $container, $entityId, $copiedEntityId)
76 {
77 $this->copyUfFields($entityId, $copiedEntityId, $this->ufEntityObject);
78
79 return new Result();
80 }
81
82 public function update($entityId, array $fields)
83 {
84 return \CBlogComment::update($entityId, $fields);
85 }
86
87 public function getText($entityId)
88 {
89 $queryObject = \CBlogComment::getlist([], ["ID" => $entityId], false, false, ["POST_TEXT"]);
90
91 if ($fields = $queryObject->fetch())
92 {
93 return ["POST_TEXT", $fields["POST_TEXT"]];
94 }
95 else
96 {
97 return ["POST_TEXT", ""];
98 }
99 }
100}
update($entityId, array $fields)
getFields(Container $container, $entityId)
add(Container $container, array $fields)
copyChildren(Container $container, $entityId, $copiedEntityId)
prepareFieldsToCopy(Container $container, array $fields)
copyUfFields(int $entityId, int $copiedEntityId, string $ufObject)