Skip to content

Commit

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

* Removed new code

* Mage_Core fixes

- changes from reviews
- added some @methods
- reverted some changes in code style for less diffs

* DOC update

* Minor fixes
  • Loading branch information
sreichel authored Jun 5, 2020
1 parent c4f437a commit 8ca6fd9
Show file tree
Hide file tree
Showing 200 changed files with 2,714 additions and 1,454 deletions.
91 changes: 56 additions & 35 deletions app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@
* @category Mage
* @package Mage_Core
* @author Magento Core Team <core@magentocommerce.com>
*
* @method $this setAdditionalHtml(string $value)
* @method $this setBlockParams(array $value)
* @method $this setCacheLifetime(int|false $value)
* @method $this setCacheKey(string $value)
* @method $this setCacheTags(array $value)
* @method $this setClass(string $value)
* @method $this setDisabled(bool $value)
* @method string getFormKey()
* @method $this setLabel(string $value)
* @method $this setOnclick(string $value)
* @method string getPosition()
* @method $this setTemplate(string $value)
* @method $this setType(string $value)
* @method bool hasWrapperMustBeVisible()
*/
abstract class Mage_Core_Block_Abstract extends Varien_Object
{
Expand Down Expand Up @@ -88,7 +103,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
/**
* Contains references to child block objects
*
* @var array
* @var Mage_Core_Block_Abstract[]
*/
protected $_children = array();

Expand Down Expand Up @@ -255,7 +270,7 @@ public function getRequest()
/**
* Retrieve parent block
*
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function getParentBlock()
{
Expand All @@ -266,7 +281,7 @@ public function getParentBlock()
* Set parent block
*
* @param Mage_Core_Block_Abstract $block
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setParentBlock(Mage_Core_Block_Abstract $block)
{
Expand All @@ -288,7 +303,7 @@ public function getAction()
* Set layout object
*
* @param Mage_Core_Model_Layout $layout
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setLayout(Mage_Core_Model_Layout $layout)
{
Expand All @@ -304,7 +319,7 @@ public function setLayout(Mage_Core_Model_Layout $layout)
*
* You can redefine this method in child classes for changing layout
*
* @return Mage_Core_Block_Abstract
* @return $this
*/
protected function _prepareLayout()
{
Expand Down Expand Up @@ -334,7 +349,7 @@ public function getIsAnonymous()
* Set the anonymous flag
*
* @param bool $flag
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setIsAnonymous($flag)
{
Expand All @@ -356,7 +371,7 @@ public function getAnonSuffix()
* Set anonymous suffix for current block
*
* @param string $suffix
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setAnonSuffix($suffix)
{
Expand All @@ -378,7 +393,7 @@ public function getBlockAlias()
* Set block alias
*
* @param string $alias
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setBlockAlias($alias)
{
Expand All @@ -390,7 +405,7 @@ public function setBlockAlias($alias)
* Set block's name in layout and unsets previous link if such exists.
*
* @param string $name
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setNameInLayout($name)
{
Expand Down Expand Up @@ -420,7 +435,7 @@ public function getSortedChildren()
*
* @param string $name
* @param mixed $value
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setAttribute($name, $value = null)
{
Expand All @@ -432,7 +447,7 @@ public function setAttribute($name, $value = null)
*
* @param string $alias
* @param Mage_Core_Block_Abstract $block
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setChild($alias, $block)
{
Expand Down Expand Up @@ -473,7 +488,7 @@ public function setChild($alias, $block)
* Unset child block
*
* @param string $alias
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function unsetChild($alias)
{
Expand Down Expand Up @@ -508,7 +523,7 @@ public function unsetChild($alias)
* @param string $callback
* @param mixed $result
* @param array $params
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function unsetCallChild($alias, $callback, $result, $params)
{
Expand All @@ -532,7 +547,7 @@ public function unsetCallChild($alias, $callback, $result, $params)
/**
* Unset all children blocks
*
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function unsetChildren()
{
Expand Down Expand Up @@ -608,7 +623,7 @@ public function getChildChildHtml($name, $childName = '', $useCache = true, $sor
/**
* Obtain sorted child blocks
*
* @return array
* @return Mage_Core_Block_Abstract[]
*/
public function getSortedChildBlocks()
{
Expand Down Expand Up @@ -737,7 +752,7 @@ public function insert($block, $siblingName = '', $after = false, $alias = '')
* Sort block's children
*
* @param boolean $force force re-sort all children
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function sortChildren($force = false)
{
Expand Down Expand Up @@ -784,7 +799,7 @@ public function sortChildren($force = false)
*
* @param Mage_Core_Block_Abstract|string $block
* @param string $alias
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function append($block, $alias = '')
{
Expand Down Expand Up @@ -812,7 +827,7 @@ public function addToChildGroup($groupName, Mage_Core_Block_Abstract $child)
* Add self to the specified group of parent block
*
* @param string $groupName
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function addToParentGroup($groupName)
{
Expand Down Expand Up @@ -849,7 +864,6 @@ public function getChildGroup($groupName, $callback = null, $skipEmptyResults =
} else {
$result[$alias] = $block;
}

}
}
return $result;
Expand All @@ -873,7 +887,7 @@ public function getChildData($alias, $key = '')
/**
* Before rendering html, but after trying to load cache
*
* @return Mage_Core_Block_Abstract
* @return $this
*/
protected function _beforeToHtml()
{
Expand All @@ -885,7 +899,7 @@ protected function _beforeToHtml()
*
* @param $openTag
* @param $closeTag
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setFrameTags($openTag, $closeTag = null)
{
Expand Down Expand Up @@ -914,7 +928,7 @@ final public function toHtml()
$html = $this->_loadCache();
if ($html === false) {
$translate = Mage::getSingleton('core/translate');
/** @var $translate Mage_Core_Model_Translate */
/** @var Mage_Core_Model_Translate $translate */
if ($this->hasData('translate_inline')) {
$translate->setTranslateInline($this->getData('translate_inline'));
}
Expand Down Expand Up @@ -943,8 +957,10 @@ final public function toHtml()
self::$_transportObject = new Varien_Object;
}
self::$_transportObject->setHtml($html);
Mage::dispatchEvent('core_block_abstract_to_html_after',
array('block' => $this, 'transport' => self::$_transportObject));
Mage::dispatchEvent(
'core_block_abstract_to_html_after',
array('block' => $this, 'transport' => self::$_transportObject)
);
$html = self::$_transportObject->getHtml();

return $html;
Expand Down Expand Up @@ -1072,7 +1088,7 @@ public function getMessagesBlock()
* Set messages block
*
* @param Mage_Core_Block_Messages $block
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function setMessagesBlock(Mage_Core_Block_Messages $block)
{
Expand All @@ -1084,7 +1100,7 @@ public function setMessagesBlock(Mage_Core_Block_Messages $block)
* Return block helper
*
* @param string $type
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function getHelper($type)
{
Expand Down Expand Up @@ -1161,8 +1177,11 @@ public function __()
}

/**
* @deprecated after 1.4.0.0-rc1
* @param string|array $data
* @param array $allowedTags
* @return string
* @see self::escapeHtml()
* @deprecated after 1.4.0.0-rc1
*/
public function htmlEscape($data, $allowedTags = null)
{
Expand All @@ -1172,7 +1191,7 @@ public function htmlEscape($data, $allowedTags = null)
/**
* Escape html entities
*
* @param mixed $data
* @param string|array $data
* @param array $allowedTags
* @return string
*/
Expand All @@ -1195,6 +1214,8 @@ public function stripTags($data, $allowableTags = null, $allowHtmlEntities = fal
}

/**
* @param string $data
* @return string
* @deprecated after 1.4.0.0-rc1
* @see self::escapeUrl()
*/
Expand Down Expand Up @@ -1261,7 +1282,7 @@ public function countChildren()
/**
* Prepare url for save to cache
*
* @return Mage_Core_Block_Abstract
* @return $this
*/
protected function _beforeCacheUrl()
{
Expand Down Expand Up @@ -1353,7 +1374,7 @@ public function getCacheTags()
* Add tag to block
*
* @param string|array $tag
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function addCacheTag($tag)
{
Expand All @@ -1368,7 +1389,7 @@ public function addCacheTag($tag)
* Add tags from specified model to current block
*
* @param Mage_Core_Model_Abstract $model
* @return Mage_Core_Block_Abstract
* @return $this
*/
public function addModelTags(Mage_Core_Model_Abstract $model)
{
Expand Down Expand Up @@ -1414,7 +1435,7 @@ protected function _loadCache()
return false;
}
$cacheKey = $this->getCacheKey();
/** @var $session Mage_Core_Model_Session */
/** @var Mage_Core_Model_Session $session */
$session = Mage::getSingleton('core/session');
$cacheData = $this->_getApp()->loadCache($cacheKey);
if ($cacheData) {
Expand All @@ -1431,15 +1452,15 @@ protected function _loadCache()
* Save block content to cache storage
*
* @param string $data
* @return Mage_Core_Block_Abstract
* @return $this|false
*/
protected function _saveCache($data)
{
if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
return false;
}
$cacheKey = $this->getCacheKey();
/** @var $session Mage_Core_Model_Session */
/** @var Mage_Core_Model_Session $session */
$session = Mage::getSingleton('core/session');
$data = str_replace(
$session->getSessionIdQueryParam() . '=' . $session->getEncryptedSessionId(),
Expand Down Expand Up @@ -1497,7 +1518,7 @@ protected function _getSidPlaceholder($cacheKey = null)
public function getItemsTags($items)
{
$tags = array();
/** @var $item Mage_Core_Model_Abstract */
/** @var Mage_Core_Model_Abstract $item */
foreach ($items as $item) {
$itemTags = $item->getCacheIdTags();
if (false === $itemTags) {
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Block/Flush.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Immediate flush block. To be used only as root
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Core_Block_Flush extends Mage_Core_Block_Abstract
{

/**
* @return string
*/
protected function _toHtml()
{
if (!$this->_beforeToHtml()) {
Expand All @@ -49,5 +50,4 @@ protected function _toHtml()
echo $block->toHtml();
}
}

}
6 changes: 5 additions & 1 deletion app/code/core/Mage/Core/Block/Html/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
*/
class Mage_Core_Block_Html_Calendar extends Mage_Core_Block_Template
{
/**
* @return string
* @throws Zend_Locale_Exception
*/
protected function _toHtml()
{
$localeCode = Mage::app()->getLocale()->getLocaleCode();
Expand Down Expand Up @@ -61,7 +65,7 @@ protected function _toHtml()
$this->assign('pm', Mage::helper('core')->jsonEncode(Zend_Locale_Data::getContent($localeCode, 'pm')));

// get first day of week and weekend days
$this->assign('firstDay', (int)Mage::getStoreConfig('general/locale/firstday'));
$this->assign('firstDay', (int)Mage::getStoreConfig('general/locale/firstday'));
$this->assign('weekendDays', Mage::helper('core')->jsonEncode((string)Mage::getStoreConfig('general/locale/weekend')));

// define default format and tooltip format
Expand Down
Loading

0 comments on commit 8ca6fd9

Please sign in to comment.