• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/entity/base.php
  • Класс: BitrixMainEntityBase
  • Вызов: Base::postInitialize
public function postInitialize()
{
	// basic properties
	$classPath = explode('\', ltrim($this->className, '\'));
	$this->name = substr(end($classPath), 0, -5);

	// default db table name
	if (is_null($this->dbTableName))
	{
		$_classPath = array_slice($classPath, 0, -1);

		$this->dbTableName = 'b_';

		foreach ($_classPath as $i => $_pathElem)
		{
			if ($i == 0 && $_pathElem == 'Bitrix')
			{
				// skip bitrix namespace
				continue;
			}

			if ($i == 1 && $_pathElem == 'Main')
			{
				// also skip Main module
				continue;
			}

			$this->dbTableName .= strtolower($_pathElem).'_';
		}

		// add class
		if ($this->name !== end($_classPath))
		{
			$this->dbTableName .= Base::camel2snake($this->name);
		}
		else
		{
			$this->dbTableName = substr($this->dbTableName, 0, -1);
		}
	}

	$this->primary = array();
	$this->references = array();

	// attributes
	foreach ($this->fieldsMap as $fieldName => &$fieldInfo)
	{
		$this->addField($fieldInfo, $fieldName);
	}

	if (!empty($this->fieldsMap) && empty($this->primary))
	{
		throw new MainSystemException(sprintf('Primary not found for %s Entity', $this->name));
	}

	// attach userfields
	if (empty($this->uf_id))
	{
		// try to find ENTITY_ID by map
		$userTypeManager = MainApplication::getUserTypeManager();
		if($userTypeManager)
		{
			$entityList = $userTypeManager->getEntityList();
			$ufId = is_array($entityList) ? array_search($this->className, $entityList) : false;
			if ($ufId !== false)
			{
				$this->uf_id = $ufId;
			}
		}
	}

	if (!empty($this->uf_id))
	{
		MainUserFieldTable::attachFields($this, $this->uf_id);
	}
}