PieWidget::prepareData

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. PieWidget
  4. prepareData
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/piewidget.php
  • Класс: Bitrix\Crm\Widget\PieWidget
  • Вызов: PieWidget::prepareData
public function prepareData()
{
	/** @var WidgetConfig|null $config */
	$config = count($this->configs) > 0 ? $this->configs[0] : null;
	if($config === null)
	{
		return array();
	}

	$this->filter->setExtras($config->getFilterParams());

	$source = null;
	$sourceSettings = $config->getDataSourceSettings();
	if(DataSourceFactory::checkSettings($sourceSettings))
	{
		$source = DataSourceFactory::create($sourceSettings, $this->userID, $this->enablePermissionCheck);
		$source->setFilterContextData($this->getFilterContextData());
	}

	$selectField = $config->getSelectField();
	$aggregate = $config->getAggregate();
	$groupField = $this->groupField !== '' ? $this->groupField : $config->getGroupField();

	if($source !== null)
	{
		$items = $source->getList(
			array(
				'filter' => $this->filter,
				'select' => array(array('name' => $selectField, 'aggregate' => $aggregate)),
				'group' => $groupField,
				'sort' => array(array('name' => $selectField))
			)
		);
	}
	else
	{
		$items = array();
	}

	return array('items' => $items, 'valueField' => $selectField, 'titleField' => $groupField);
}

Добавить комментарий