Public Member Functions | |
__construct ($container) | |
getIterator () | |
offsetSet ($key, $value) | |
offsetGet ($key) | |
offsetUnset ($key) | |
offsetExists ($key) | |
add (Varien_Data_Form_Element_Abstract $element, $after=false) | |
usort ($callback) | |
remove ($elementId) | |
count () | |
searchById ($elementId) |
Definition at line 34 of file Collection.php.
__construct | ( | $ | container | ) |
Class constructor
Varien_Data_Form_Abstract | $container |
Definition at line 56 of file Collection.php.
00057 { 00058 $this->_elements = array(); 00059 $this->_container = $container; 00060 }
add | ( | Varien_Data_Form_Element_Abstract $ | element, | |
$ | after = false | |||
) |
Add element to collection
Varien_Data_Form_Element_Abstract | $element | |
boolean|'^'|string | $after |
Definition at line 122 of file Collection.php.
00123 { 00124 // Set the Form for the node 00125 if ($this->_container->getForm() instanceof Varien_Data_Form) { 00126 $element->setContainer($this->_container); 00127 $element->setForm($this->_container->getForm()); 00128 } 00129 00130 if ($after === false) { 00131 $this->_elements[] = $element; 00132 } 00133 elseif ($after === '^') { 00134 array_unshift($this->_elements, $element); 00135 } 00136 elseif (is_string($after)) { 00137 $newOrderElements = array(); 00138 foreach ($this->_elements as $index => $currElement) { 00139 if ($currElement->getId() == $after) { 00140 $newOrderElements[] = $currElement; 00141 $newOrderElements[] = $element; 00142 $this->_elements = array_merge($newOrderElements, array_slice($this->_elements, $index+1)); 00143 return $element; 00144 } 00145 $newOrderElements[] = $currElement; 00146 } 00147 $this->_elements[] = $element; 00148 } 00149 00150 return $element; 00151 }
count | ( | ) |
Count elements in collection
Definition at line 186 of file Collection.php.
00187 { 00188 return count($this->_elements); 00189 }
getIterator | ( | ) |
Implementation of IteratorAggregate.getIterator()
Definition at line 67 of file Collection.php.
offsetExists | ( | $ | key | ) |
Implementation of ArrayAccess:offsetExists()
mixed | $key |
Definition at line 109 of file Collection.php.
offsetGet | ( | $ | key | ) |
Implementation of ArrayAccess:offsetGet()
mixed | $key |
Definition at line 88 of file Collection.php.
offsetSet | ( | $ | key, | |
$ | value | |||
) |
Implementation of ArrayAccess:offsetSet()
mixed | $key | |
mixed | $value |
Definition at line 78 of file Collection.php.
offsetUnset | ( | $ | key | ) |
Implementation of ArrayAccess:offsetUnset()
mixed | $key |
Definition at line 98 of file Collection.php.
remove | ( | $ | elementId | ) |
Remove element from collection
mixed | $elementId |
Definition at line 171 of file Collection.php.
00172 { 00173 foreach ($this->_elements as $index => $element) { 00174 if ($elementId == $element->getId()) { 00175 unset($this->_elements[$index]); 00176 } 00177 } 00178 return $this; 00179 }
searchById | ( | $ | elementId | ) |
Find element by ID
mixed | $elementId |
Definition at line 197 of file Collection.php.
00198 { 00199 foreach ($this->_elements as $element) { 00200 if ($element->getId() == $elementId) { 00201 return $element; 00202 } 00203 } 00204 return null; 00205 }
usort | ( | $ | callback | ) |
Sort elements by values using a user-defined comparison function
mixed | $callback |
Definition at line 159 of file Collection.php.
00160 { 00161 usort($this->_elements, $callback); 00162 return $this; 00163 }