Your IP : 3.135.224.236


Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/modules/ui/lib/buttons/
Upload File :
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/modules/ui/lib/buttons/intranetbindingmenu.php

<?php

namespace Bitrix\UI\Buttons;

use Bitrix\Main\Loader;

class IntranetBindingMenu extends Button
{
	protected $componentParameters = [];
	protected $content;

	public static function isAvailable(): bool
	{
		return Loader::includeModule('intranet');
	}

	public static function createByComponentParameters(array $parameters): ?self
	{
		if(!static::isAvailable())
		{
			return null;
		}

		return new static([
			'componentParameters' => $parameters,
		]);
	}

	protected function init(array $params = [])
	{
		$this->componentParameters = $params['componentParameters'] ?? [];

		$this->content = $this->preRender();
	}

	protected function preRender(): string
	{
		$result = '';

		if(empty($this->componentParameters))
		{
			return $result;
		}

		global $APPLICATION;
		ob_start();
		$APPLICATION->IncludeComponent(
			'bitrix:intranet.binding.menu',
			'',
			$this->componentParameters
		);
		$result = ob_get_contents();
		ob_end_clean();

		return $result;
	}

	public function render($jsInit = true): string
	{
		return $this->content;
	}
}