Skip to content

Commit

Permalink
Mage_Checkout - DOC block update (#775)
Browse files Browse the repository at this point in the history
* Mage_Checkout - DOC block update

- doc blocks added/fixed
- PSR2 fixes (whitespaces, linebreaks, ...)

* Fixed mixed return types
  • Loading branch information
sreichel authored Jun 5, 2020
1 parent 744ee11 commit c4f437a
Show file tree
Hide file tree
Showing 73 changed files with 1,017 additions and 393 deletions.
11 changes: 11 additions & 0 deletions app/code/core/Mage/Checkout/Block/Agreements.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,19 @@
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Class Mage_Checkout_Block_Agreements
*
* @method bool hasAgreements()
* @method $this setAgreements(Mage_Checkout_Model_Resource_Agreement_Collection $value)
*/
class Mage_Checkout_Block_Agreements extends Mage_Core_Block_Template
{
/**
* @return mixed
* @throws Mage_Core_Model_Store_Exception
*/
public function getAgreements()
{
if (!$this->hasAgreements()) {
Expand Down
31 changes: 27 additions & 4 deletions app/code/core/Mage/Checkout/Block/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
* @category Mage
* @package Mage_Checkout
* @author Magento Core Team <core@magentocommerce.com>
*
* @method string getCartTemplate()
* @method string getEmptyTemplate()
* @method $this setIsWishlistActive(bool $value)
* @method int getItemsCount()
* @method Mage_Sales_Model_Quote_Item[] getCustomItems()
*/
class Mage_Checkout_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
{
Expand All @@ -50,7 +56,7 @@ public function __construct()
public function prepareItemUrls()
{
$products = array();
/* @var $item Mage_Sales_Model_Quote_Item */
/* @var Mage_Sales_Model_Quote_Item $item */
foreach ($this->getItems() as $item) {
$product = $item->getProduct();
$option = $item->getOptionByCode('product_type');
Expand All @@ -60,8 +66,7 @@ public function prepareItemUrls()

if ($item->getStoreId() != Mage::app()->getStore()->getId()
&& !$item->getRedirectUrl()
&& !$product->isVisibleInSiteVisibility())
{
&& !$product->isVisibleInSiteVisibility()) {
$products[$product->getId()] = $item->getStoreId();
}
}
Expand Down Expand Up @@ -94,16 +99,25 @@ public function chooseTemplate()
}
}

/**
* @return bool
*/
public function hasError()
{
return $this->getQuote()->getHasError();
}

/**
* @return float|int|mixed
*/
public function getItemsSummaryQty()
{
return $this->getQuote()->getItemsSummaryQty();
}

/**
* @return bool|mixed
*/
public function isWishlistActive()
{
$isActive = $this->_getData('is_wishlist_active');
Expand All @@ -115,6 +129,9 @@ public function isWishlistActive()
return $isActive;
}

/**
* @return string
*/
public function getCheckoutUrl()
{
return $this->getUrl('checkout/onepage', array('_secure'=>true));
Expand All @@ -130,6 +147,9 @@ public function getFormActionUrl()
return $this->getUrl('checkout/cart/updatePost', array('_secure' => $this->_isSecure()));
}

/**
* @return mixed|string
*/
public function getContinueShoppingUrl()
{
$url = $this->getData('continue_shopping_url');
Expand All @@ -143,6 +163,9 @@ public function getContinueShoppingUrl()
return $url;
}

/**
* @return bool
*/
public function getIsVirtual()
{
return $this->helper('checkout/cart')->getIsVirtualQuote();
Expand Down Expand Up @@ -180,7 +203,7 @@ public function getMethodHtml($name)
/**
* Return customer quote items
*
* @return array
* @return Mage_Sales_Model_Quote_Item[]
*/
public function getItems()
{
Expand Down
9 changes: 8 additions & 1 deletion app/code/core/Mage/Checkout/Block/Cart/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getItemRendererInfo($type)
return $this->_itemRenders[$type];
}
return $this->_itemRenders['default'];
}
}

/**
* Get renderer block instance by product type code
Expand Down Expand Up @@ -170,15 +170,22 @@ public function getItems()
*/
public function getItemHtml(Mage_Sales_Model_Quote_Item $item)
{
/** @var Mage_Checkout_Block_Cart_Item_Renderer $renderer */
$renderer = $this->getItemRenderer($item->getProductType())->setItem($item);
return $renderer->toHtml();
}

/**
* @return array
*/
public function getTotals()
{
return $this->getTotalsCache();
}

/**
* @return array
*/
public function getTotalsCache()
{
if (empty($this->_totals)) {
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Checkout/Block/Cart/Coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

class Mage_Checkout_Block_Cart_Coupon extends Mage_Checkout_Block_Cart_Abstract
{
/**
* @return string
*/
public function getCouponCode()
{
return $this->getQuote()->getCouponCode();
Expand All @@ -41,5 +44,4 @@ public function getFormActionUrl()
{
return $this->getUrl('checkout/cart/couponPost', array('_secure' => $this->_isSecure()));
}

}
4 changes: 2 additions & 2 deletions app/code/core/Mage/Checkout/Block/Cart/Crosssell.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getItems()
}
$collection->setPositionOrder()->load();

/** @var Mage_Catalog_Model_Product_Link $item */
foreach ($collection as $item) {
$ninProductIds[] = $item->getId();
$items[] = $item;
Expand All @@ -80,7 +81,6 @@ public function getItems()
$items[] = $item;
}
}

}

$this->setData('items', $items);
Expand Down Expand Up @@ -163,7 +163,7 @@ public function getQuote()
/**
* Get crosssell products collection
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection
* @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection
*/
protected function _getCollection()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Block/Cart/Item/Configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Mage_Checkout_Block_Cart_Item_Configure extends Mage_Core_Block_Template
/**
* Configure product view blocks
*
* @return $this
* @inheritDoc
*/
protected function _prepareLayout()
{
Expand Down
29 changes: 20 additions & 9 deletions app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
* @package Mage_Checkout
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Checkout_Block_Cart_Item_Renderer setProductName(string)
* @method Mage_Checkout_Block_Cart_Item_Renderer setDeleteUrl(string)
* @method bool hasProductName()
* @method $this setProductName(string)
* @method bool hasDeleteUrl()
* @method $this setDeleteUrl(string)
* @method string getIdSuffix()
*/
class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
{
Expand All @@ -59,8 +62,8 @@ class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
/**
* Set item for render
*
* @param Mage_Sales_Model_Quote_Item $item
* @return Mage_Checkout_Block_Cart_Item_Renderer
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return $this
*/
public function setItem(Mage_Sales_Model_Quote_Item_Abstract $item)
{
Expand Down Expand Up @@ -88,6 +91,10 @@ public function getProduct()
return $this->getItem()->getProduct();
}

/**
* @param Mage_Catalog_Helper_Image $productThumbnail
* @return $this
*/
public function overrideProductThumbnail($productThumbnail)
{
$this->_productThumbnail = $productThumbnail;
Expand All @@ -97,7 +104,7 @@ public function overrideProductThumbnail($productThumbnail)
/**
* Get product thumbnail image
*
* @return Mage_Catalog_Model_Product_Image
* @return Mage_Catalog_Helper_Image
*/
public function getProductThumbnail()
{
Expand All @@ -107,6 +114,10 @@ public function getProductThumbnail()
return $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail');
}

/**
* @param string $productUrl
* @return $this
*/
public function overrideProductUrl($productUrl)
{
$this->_productUrl = $productUrl;
Expand Down Expand Up @@ -181,7 +192,7 @@ public function getProductName()
*/
public function getProductOptions()
{
/* @var $helper Mage_Catalog_Helper_Product_Configuration */
/* @var Mage_Catalog_Helper_Product_Configuration $helper */
$helper = Mage::helper('catalog/product_configuration');
return $helper->getCustomOptions($this->getItem());
}
Expand Down Expand Up @@ -345,12 +356,12 @@ public function getMessages()
// Add messages saved previously in checkout session
$checkoutSession = $this->getCheckoutSession();
if ($checkoutSession) {
/* @var $collection Mage_Core_Model_Message_Collection */
/* @var Mage_Core_Model_Message_Collection $collection */
$collection = $checkoutSession->getQuoteItemMessages($quoteItem->getId(), true);
if ($collection) {
$additionalMessages = $collection->getItems();
foreach ($additionalMessages as $message) {
/* @var $message Mage_Core_Model_Message_Abstract */
/* @var Mage_Core_Model_Message_Abstract $message */
$messages[] = array(
'text' => $message->getCode(),
'type' => ($message->getType() == Mage_Core_Model_Message::ERROR) ? 'error' : 'notice'
Expand Down Expand Up @@ -384,7 +395,7 @@ public function getMessages()
*/
public function getFormatedOptionValue($optionValue)
{
/* @var $helper Mage_Catalog_Helper_Product_Configuration */
/* @var Mage_Catalog_Helper_Product_Configuration $helper */
$helper = Mage::helper('catalog/product_configuration');
$params = array(
'max_length' => 55,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getProductAttributes()
*/
public function getOptionList()
{
/* @var $helper Mage_Catalog_Helper_Product_Configuration */
/* @var Mage_Catalog_Helper_Product_Configuration $helper */
$helper = Mage::helper('catalog/product_configuration');
$options = $helper->getConfigurableOptions($this->getItem());
return $options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* @category Mage
* @package Mage_Checkout
* @author Magento Core Team <core@magentocommerce.com>
*
* @method \Mage_Checkout_Block_Cart_Sidebar getRenderedBlock()
*/
class Mage_Checkout_Block_Cart_Item_Renderer_Grouped extends Mage_Checkout_Block_Cart_Item_Renderer
{
Expand All @@ -53,7 +55,7 @@ public function getGroupedProduct()
/**
* Get product thumbnail image
*
* @return Mage_Catalog_Model_Product_Image
* @return Mage_Catalog_Helper_Image
*/
public function getProductThumbnail()
{
Expand All @@ -75,6 +77,7 @@ public function getProductThumbnail()
*/
protected function _toHtml()
{
/** @var Mage_Checkout_Block_Cart_Item_Renderer $renderer */
$renderer = $this->getRenderedBlock()->getItemRenderer($this->getItem()->getRealProductType());
$renderer->setItem($this->getItem());
// $renderer->overrideProductUrl($this->getProductUrl());
Expand Down
11 changes: 6 additions & 5 deletions app/code/core/Mage/Checkout/Block/Cart/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getSubtotal($skipTax = true)
} else {
$subtotal = $totals['subtotal']->getValueInclTax();
}
} elseif($config->displayCartSubtotalInclTax()) {
} elseif ($config->displayCartSubtotalInclTax()) {
$subtotal = $totals['subtotal']->getValueInclTax();
} else {
$subtotal = $totals['subtotal']->getValue();
Expand Down Expand Up @@ -131,7 +131,8 @@ public function getSubtotalInclTax()
* @param bool $exclShippingTax
* @return float
*/
private function _addTax($price, $exclShippingTax=true) {
private function _addTax($price, $exclShippingTax = true)
{
$totals = $this->getTotals();
if (isset($totals['tax'])) {
if ($exclShippingTax) {
Expand Down Expand Up @@ -210,7 +211,7 @@ public function getItems()
return parent::getItems();
}

/*
/**
* Return totals from custom quote if needed
*
* @return array
Expand Down Expand Up @@ -286,10 +287,10 @@ public function getCacheTags()
$quoteTags = $this->getQuote()->getCacheIdTags();

$items = array();
/** @var $item Mage_Sales_Model_Quote_Item */
/** @var Mage_Sales_Model_Quote_Item $item */
foreach ($this->getItems() as $item) {
$items[] = $item->getProduct();
}
}

return array_merge(
parent::getCacheTags(),
Expand Down
Loading

0 comments on commit c4f437a

Please sign in to comment.