Back to Table class

Method _getAssetParentId

protected int
_getAssetParentId
(\Joomla\CMS\Table\Table $table = null, mixed $id = null)
Method to get the parent asset under which to register this one.
Parameters
  • \Joomla\CMS\Table\Table $table A Table object for the asset parent.
  • int $id Id to look up
Returns
  • int
Since
  • 1.7.0
Class: Table
Project: Joomla

Method _getAssetParentId - Source code

/**
 * 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;
}