/**
* Method to get the parent asset under which to register this one.
*
* By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists.
* An extended class can define a table and ID to lookup. If the asset does not exist it will be created.
*
* @param Table $table A Table object for the asset parent.
* @param integer $id Id to look up
*
* @return integer
*
* @since 1.7.0
*/
protected function _getAssetParentId(Table $table = null, $id = null)
{
// For simple cases, parent to the asset root.
/** @var Asset $assets */
$assets = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$rootId = $assets->getRootId();
if (!empty($rootId)) {
return $rootId;
}
return 1;
}