Method to set the location of a node in the tree object.  This method does not
save the new location to the database, but will set it in the object so
that when the node is stored it will be stored in the new location.
Parameters
- int  $referenceId  The primary key of the node to reference new location by.
 - string  $position  Location type string.
 
Returns
Since
-
- Since 3.0.0 this method returns void and throws an \InvalidArgumentException when an invalid position is passed.
 - \Joomla\CMS\Table\Nested::$_validLocations
 - \InvalidArgumentException
 
/**
 * Method to set the location of a node in the tree object.  This method does not
 * save the new location to the database, but will set it in the object so
 * that when the node is stored it will be stored in the new location.
 *
 * @param   integer  $referenceId  The primary key of the node to reference new location by.
 * @param   string   $position     Location type string.
 *
 * @return  void
 *
 * @note    Since 3.0.0 this method returns void and throws an \InvalidArgumentException when an invalid position is passed.
 * @see     Nested::$_validLocations
 * @since   1.7.0
 * @throws  \InvalidArgumentException
 */
public function setLocation($referenceId, $position = 'after')
{
    // Make sure the location is valid.
    if (!\in_array($position, $this->_validLocations)) {
        throw new \InvalidArgumentException(sprintf('Invalid location "%1$s" given, valid values are %2$s', $position, implode(', ', $this->_validLocations)));
    }
    // Set the location properties.
    $this->_location = $position;
    $this->_location_id = $referenceId;
}