Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varien_ - DOC block update (1) #703

Merged
merged 6 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 60 additions & 24 deletions lib/Varien/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public function __construct()
* Add collection filter
*
* @param string $field
* @param string $value
* @param string|array $value
* @param string $type and|or|string
* @return $this
*/
public function addFilter($field, $value, $type = 'and')
{
Expand Down Expand Up @@ -188,8 +189,8 @@ public function isLoaded()
/**
* Set collection loading status flag
*
* @param unknown_type $flag
* @return unknown
* @param bool $flag
* @return $this
*/
protected function _setIsLoaded($flag = true)
{
Expand Down Expand Up @@ -344,7 +345,7 @@ public function getItemsByColumnValue($column, $value)
*
* @param string $column
* @param mixed $value
* @return Varien_Object || null
* @return Varien_Object|null
*/
public function getItemByColumnValue($column, $value)
{
Expand All @@ -362,7 +363,7 @@ public function getItemByColumnValue($column, $value)
* Adding item to item array
*
* @param Varien_Object $item
* @return Varien_Data_Collection
* @return $this
*/
public function addItem(Varien_Object $item)
{
Expand All @@ -383,7 +384,7 @@ public function addItem(Varien_Object $item)
* Add item that has no id to collection
*
* @param Varien_Object $item
* @return Varien_Data_Collection
* @return $this
*/
protected function _addItem($item)
{
Expand Down Expand Up @@ -420,7 +421,7 @@ public function getAllIds()
* Remove item from collection by item key
*
* @param mixed $key
* @return Varien_Data_Collection
* @return $this
*/
public function removeItemByKey($key)
{
Expand All @@ -433,7 +434,7 @@ public function removeItemByKey($key)
/**
* Clear collection
*
* @return Varien_Data_Collection
* @return $this
*/
public function clear()
{
Expand All @@ -448,11 +449,11 @@ public function clear()
*
* Returns array with results of callback for each item
*
* @param string $method
* @param string $callback
* @param array $args
* @return array
*/
public function walk($callback, array $args=array())
public function walk($callback, array $args = array())
{
$results = array();
$useItemCallback = is_string($callback) && strpos($callback, '::')===false;
Expand All @@ -468,7 +469,11 @@ public function walk($callback, array $args=array())
return $results;
}

public function each($obj_method, $args=array())
/**
* @param string $obj_method
* @param array $args
*/
public function each($obj_method, $args = array())
{
foreach ($args->_items as $k => $item) {
$args->_items[$k] = call_user_func($obj_method, $item);
Expand All @@ -480,7 +485,7 @@ public function each($obj_method, $args=array())
*
* @param mixed $key
* @param mixed $value
* @return Varien_Data_Collection
* @return $this
*/
public function setDataToAll($key, $value=null)
{
Expand All @@ -500,7 +505,7 @@ public function setDataToAll($key, $value=null)
* Set current page
*
* @param int $page
* @return Varien_Data_Collection
* @return $this
*/
public function setCurPage($page)
{
Expand All @@ -512,7 +517,7 @@ public function setCurPage($page)
* Set collection page size
*
* @param int $size
* @return Varien_Data_Collection
* @return $this
*/
public function setPageSize($size)
{
Expand All @@ -525,7 +530,7 @@ public function setPageSize($size)
*
* @param string $field
* @param string $direction
* @return Varien_Data_Collection
* @return $this
*/
public function setOrder($field, $direction = self::SORT_ORDER_DESC)
{
Expand All @@ -537,7 +542,7 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC)
* Set collection item class name
*
* @param string $className
* @return Varien_Data_Collection
* @return $this
*/
function setItemObjectClass($className)
{
Expand Down Expand Up @@ -596,6 +601,7 @@ protected function _renderLimit()
* Set select distinct
*
* @param bool $flag
* @return $this
*/
public function distinct($flag)
{
Expand All @@ -605,7 +611,9 @@ public function distinct($flag)
/**
* Load data
*
* @return Varien_Data_Collection
* @param bool $printQuery
* @param bool $logQuery
* @return $this
*/
public function loadData($printQuery = false, $logQuery = false)
{
Expand All @@ -615,7 +623,9 @@ public function loadData($printQuery = false, $logQuery = false)
/**
* Load data
*
* @return Varien_Data_Collection
* @param bool $printQuery
* @param bool $logQuery
* @return $this
*/
public function load($printQuery = false, $logQuery = false)
{
Expand Down Expand Up @@ -645,6 +655,7 @@ public function toXml()
/**
* Convert collection to array
*
* @param array $arrRequiredFields
* @return array
*/
public function toArray($arrRequiredFields = array())
Expand All @@ -670,12 +681,14 @@ public function toArray($arrRequiredFields = array())
* )
* )
*
* @param string $valueField
* @param string $labelField
* @return array
* @param string $valueField
* @param string $labelField
* @param array $additional
* @return array
*/
protected function _toOptionArray($valueField='id', $labelField='name', $additional=array())
protected function _toOptionArray($valueField='id', $labelField='name', $additional = array())
{
$data = array();
$res = array();
$additional['value'] = $valueField;
$additional['label'] = $labelField;
Expand All @@ -689,11 +702,17 @@ protected function _toOptionArray($valueField='id', $labelField='name', $additio
return $res;
}

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

/**
* @return array
*/
public function toOptionHash()
{
return $this->_toOptionHash();
Expand Down Expand Up @@ -722,7 +741,7 @@ protected function _toOptionHash($valueField='id', $labelField='name')
* Retrieve item by id
*
* @param mixed $idValue
* @return Varien_Object
* @return Varien_Object|null
*/
public function getItemById($idValue)
{
Expand Down Expand Up @@ -753,28 +772,45 @@ public function count()
return count($this->_items);
}

/**
* @param string $key
* @return $this
*/
public function setCacheKey($key)
{
$this->_cacheKey = $key;
return $this;
}

/**
* @return string
*/
public function getCacheKey()
{
return $this->_cacheKey;
}

/**
* @param array $tags
* @return $this
*/
public function setCacheTags($tags)
{
$this->_cacheTags = $tags;
return $this;
}

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

/**
* @return int
*/
public function getCacheLifetime()
{
return $this->_cacheLifetime;
Expand All @@ -796,7 +832,7 @@ public function getFlag($flag)
*
* @param string $flag
* @param mixed $value
* @return Varien_Data_Collection
* @return $this
*/
public function setFlag($flag, $value = null)
{
Expand Down
Loading