Magento 2 has a Magento\Framework\UrlInterface
interface/type that's mapped to the Magento\Framework\Url
object. This object has a getBaseUrl
method which you can use to fetch the base URL for the current scope.
$url = $this->url->getBaseUrl();
Is it possible to use this method (or another method?) to fetch the base URLs for every site/store in a Magento system? i.e Magento systems often have different base URLs depending on how the website, store, and store views are setup and how options like "use store code in URL" are configured. I'd like a way to fetch every URL in a particular Magento system.
The larger, underlying question here is how does the "scope" object interact with the URL building in Magento 2. Answers along those lines are more than welcome.