Varien_Data_Form_Element_Collection Class Reference

List of all members.

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)


Detailed Description

Definition at line 34 of file Collection.php.


Constructor & Destructor Documentation

__construct ( container  ) 

Class constructor

Parameters:
Varien_Data_Form_Abstract $container

Definition at line 56 of file Collection.php.

00057     {
00058         $this->_elements = array();
00059         $this->_container = $container;
00060     }


Member Function Documentation

add ( Varien_Data_Form_Element_Abstract element,
after = false 
)

Add element to collection

Todo:
get it straight with $after
Parameters:
Varien_Data_Form_Element_Abstract $element
boolean|'^'|string $after
Returns:
Varien_Data_Form_Element_Abstract

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

Returns:
int

Definition at line 186 of file Collection.php.

00187     {
00188         return count($this->_elements);
00189     }

getIterator (  ) 

Implementation of IteratorAggregate.getIterator()

Returns:
ArrayIterator

Definition at line 67 of file Collection.php.

00068     {
00069         return new ArrayIterator($this->_elements);
00070     }

offsetExists ( key  ) 

Implementation of ArrayAccess:offsetExists()

Parameters:
mixed $key
Returns:
boolean

Definition at line 109 of file Collection.php.

00110     {
00111         return isset($this->_elements[$key]);
00112     }

offsetGet ( key  ) 

Implementation of ArrayAccess:offsetGet()

Parameters:
mixed $key

Definition at line 88 of file Collection.php.

00089     {
00090         return $this->_elements[$key];
00091     }

offsetSet ( key,
value 
)

Implementation of ArrayAccess:offsetSet()

Parameters:
mixed $key
mixed $value

Definition at line 78 of file Collection.php.

00079     {
00080         $this->_elements[$key] = $value;
00081     }

offsetUnset ( key  ) 

Implementation of ArrayAccess:offsetUnset()

Parameters:
mixed $key

Definition at line 98 of file Collection.php.

00099     {
00100         unset($this->_elements[$key]);
00101     }

remove ( elementId  ) 

Remove element from collection

Parameters:
mixed $elementId
Returns:
Varien_Data_Form_Element_Collection

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

Parameters:
mixed $elementId
Returns:
Varien_Data_Form_Element_Abstract|null

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

Parameters:
mixed $callback
Returns:
Varien_Data_Form_Element_Collection

Definition at line 159 of file Collection.php.

00160     {
00161         usort($this->_elements, $callback);
00162         return $this;
00163     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:59 2009 for Magento by  doxygen 1.5.8