public function replaceEntryByPosition(
        $position,
        SwatNavBarEntry $new_entry
    ) {
        if (isset($this->entries[$position])) {
            $old_entry = $this->entries[$position];
            $this->entries[$position] = $new_entry;

            return $old_entry;
        }

        throw new SwatException(
            sprintf(
                'Cannot replace element at position ' .
                    '%s because NavBar does not contain an entry at position %s.',
                $position,
                $position
            )
        );
    }