How to get the current shopping cart details on the server-side (with PHP)? [duplicate]

Hi everyone,

I know in Magento 1 you can get the shopping cart details on any page with:

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productId = $item->getProduct()->getId();
    $productPrice = $item->getProduct()->getPrice();
}

How do I do the same thing in Magento 2?

How to get the current shopping cart details on the server-side (with PHP)?