Public Member Functions | |
__construct () | |
asArray (array $arrAttributes=array()) | |
loadArray (array $arr) | |
addAction (Mage_Rule_Model_Action_Interface $action) | |
asHtml () | |
getNewChildElement () | |
asHtmlRecursive () | |
asString ($format='') | |
asStringRecursive ($level=0) | |
process () |
Definition at line 28 of file Collection.php.
__construct | ( | ) |
Constructor
By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes
Reimplemented from Mage_Rule_Model_Action_Abstract.
Reimplemented in Mage_CatalogRule_Model_Rule_Action_Collection, and Mage_SalesRule_Model_Rule_Action_Collection.
Definition at line 30 of file Collection.php.
00031 { 00032 parent::__construct(); 00033 $this->setActions(array()); 00034 $this->setType('rule/action_collection'); 00035 }
addAction | ( | Mage_Rule_Model_Action_Interface $ | action | ) |
Definition at line 73 of file Collection.php.
00074 { 00075 $actions = $this->getActions(); 00076 00077 $action->setRule($this->getRule()); 00078 00079 $actions[] = $action; 00080 if (!$action->getId()) { 00081 $action->setId($this->getId().'.'.sizeof($actions)); 00082 } 00083 00084 $this->setActions($actions); 00085 return $this; 00086 }
Returns array containing actions in the collection
Output example: array( {action.asArray}, {action.asArray} )
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 48 of file Collection.php.
00049 { 00050 $out = parent::asArray(); 00051 00052 foreach ($this->getActions() as $item) { 00053 $out['actions'][] = $item->asArray(); 00054 } 00055 return $out; 00056 }
asHtml | ( | ) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 88 of file Collection.php.
00089 { 00090 $html = $this->getTypeElement()->toHtml().'Perform following actions: '; 00091 if ($this->getId()!='1') { 00092 $html.= $this->getRemoveLinkHtml(); 00093 } 00094 return $html; 00095 }
asHtmlRecursive | ( | ) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 105 of file Collection.php.
00106 { 00107 $html = $this->asHtml().'<ul id="action:'.$this->getId().':children">'; 00108 foreach ($this->getActions() as $cond) { 00109 $html .= '<li>'.$cond->asHtmlRecursive().'</li>'; 00110 } 00111 $html .= '<li>'.$this->getNewChildElement()->getHtml().'</li></ul>'; 00112 return $html; 00113 }
asString | ( | $ | format = '' |
) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 115 of file Collection.php.
00116 { 00117 $str = Mage::helper('rule')->__("Perform following actions"); 00118 return $str; 00119 }
asStringRecursive | ( | $ | level = 0 |
) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 121 of file Collection.php.
00122 { 00123 $str = $this->asString(); 00124 foreach ($this->getActions() as $action) { 00125 $str .= "\n".$action->asStringRecursive($level+1); 00126 } 00127 return $str; 00128 }
getNewChildElement | ( | ) |
Definition at line 96 of file Collection.php.
00097 { 00098 return $this->getForm()->addField('action:'.$this->getId().':new_child', 'select', array( 00099 'name'=>'rule[actions]['.$this->getId().'][new_child]', 00100 'values'=>$this->getNewChildSelectOptions(), 00101 'value_name'=>$this->getNewChildName(), 00102 ))->setRenderer(Mage::getBlockSingleton('rule/newchild')); 00103 }
loadArray | ( | array $ | arr | ) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 58 of file Collection.php.
00059 { 00060 if (!empty($arr['actions']) && is_array($arr['actions'])) { 00061 foreach ($arr['actions'] as $actArr) { 00062 if (empty($actArr['type'])) { 00063 continue; 00064 } 00065 $action = Mage::getModel($actArr['type']); 00066 $action->loadArray($actArr); 00067 $this->addAction($action); 00068 } 00069 } 00070 return $this; 00071 }
process | ( | ) |
Reimplemented from Mage_Rule_Model_Action_Abstract.
Definition at line 130 of file Collection.php.
00131 { 00132 foreach ($this->getActions() as $action) { 00133 $action->process(); 00134 } 00135 return $this; 00136 }