2declare(strict_types=1);
15 private string $section;
24 private string $bgType;
26 private string $menuTitle;
27 private array $wrapperClasses;
32 private array $nodes = [];
33 private array $styles = [];
42 public function __construct(
string $code,
string $section,
string $bgType)
45 $this->section = $section;
46 $this->bgType = $bgType;
87 return $this->section;
97 return $this->section === Collector::SECTIONS[
'MENU'];
107 return $this->section === Collector::SECTIONS[
'SEPARATORS'];
117 return $this->section === Collector::SECTIONS[
'COVER'];
127 return $this->section === Collector::SECTIONS[
'TITLE'];
138 return $this->bgType;
150 $this->bgType = $bgType;
162 return $this->menuTitle ??
'';
174 $this->menuTitle = $menuTitle;
181 $this->styles = $styles;
188 return $this->styles;
198 return $this->
id ?? 0;
203 return 'block' . $id;
213 public function setId(
int $id): self
229 $node->setParentBlock($this);
230 $this->nodes[] = $node;
247 return array_filter($this->nodes,
function (
Node $node) use ($codes)
249 return in_array($node->getCode(), $codes,
true);
260 return $this->wrapperClasses ?? [];
272 $this->wrapperClasses = $classes;
286 $data[
'section'] = $this->section;
287 $data[
'bgType'] = $this->bgType;
288 $data[
'styles'] = $this->styles;
290 if (isset($this->
id))
292 $data[
'id'] = $this->id;
296 foreach ($this->nodes as $node)
298 $data[
'nodes'][] = $node->toArray();
313 $code =
$data[
'code'] ??
null;
314 $section =
$data[
'section'] ??
null;
315 $bgType =
$data[
'bgType'] ??
null;
316 $styles =
$data[
'styles'] ?? [];
318 if (!$code || $section ===
null || $bgType ===
null)
321 GenerationErrors::dataValidation,
322 "Not exist key block data in array.",
326 $blockData =
new Block($code, $section, $bgType);
328 $id = (int)(
$data[
'id'] ?? 0);
331 $blockData->setId($id);
336 $blockData->setStyles($styles);
339 foreach ((
$data[
'nodes'] ?? []) as $node)
346 $blockData->addNode($node);
static fromArray(array $data)
setParentSite(Site $site)
setMenuTitle(string $menuTitle)
static getAnchor(int $id)
setBgType(string $bgType)
setWrapperClasses(array $classes)
__construct(string $code, string $section, string $bgType)
getNodes(?array $codes=null)
static fromArray(array $data)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code