Mage_Dataflow_Model_Convert_Action_Abstract Class Reference

Inheritance diagram for Mage_Dataflow_Model_Convert_Action_Abstract:

Mage_Dataflow_Model_Convert_Action_Interface Mage_Dataflow_Model_Convert_Action

List of all members.

Public Member Functions

 getParam ($key, $default=null)
 setParam ($key, $value=null)
 getParams ()
 setParams ($params)
 getProfile ()
 setProfile (Mage_Dataflow_Model_Convert_Profile_Interface $profile)
 addAction (Mage_Dataflow_Model_Convert_Action_Interface $action=null)
 setContainer (Mage_Dataflow_Model_Convert_Container_Interface $container)
 getContainer ($name=null)
 importXml (Varien_Simplexml_Element $actionNode)
 run (array $args=array())
 runActions (array $args=array())

Protected Attributes

 $_params
 $_profile
 $_actions = array()
 $_container
 $_actionDefaultClass = 'Mage_Dataflow_Model_Convert_Action'


Detailed Description

Definition at line 37 of file Abstract.php.


Member Function Documentation

addAction ( Mage_Dataflow_Model_Convert_Action_Interface action = null  ) 

Definition at line 144 of file Abstract.php.

00145     {
00146         if (is_null($action)) {
00147             $action = new $this->_actionDefaultClass();
00148         }
00149         $this->_actions[] = $action;
00150         $action->setProfile($this->getProfile());
00151         return $action;
00152     }

getContainer ( name = null  ) 

Get action's container

Parameters:
string $name
Returns:
Mage_Dataflow_Model_Convert_Container_Abstract

Definition at line 174 of file Abstract.php.

00175     {
00176         if (!is_null($name)) {
00177             return $this->getProfile()->getContainer($name);
00178         }
00179 
00180         if (!$this->_container) {
00181             $class = $this->getParam('class');
00182             $this->setContainer(new $class());
00183         }
00184         return $this->_container;
00185     }

getParam ( key,
default = null 
)

Get action parameter

Parameters:
string $key
mixed $default
Returns:
mixed

Definition at line 75 of file Abstract.php.

00076     {
00077         if (!isset($this->_params[$key])) {
00078             return $default;
00079         }
00080         return $this->_params[$key];
00081     }

getParams (  ) 

Get all action parameters

Returns:
array

Definition at line 105 of file Abstract.php.

00106     {
00107         return $this->_params;
00108     }

getProfile (  ) 

Get profile instance the action belongs to

Returns:
Mage_Dataflow_Model_Convert_Profile_Abstract

Definition at line 127 of file Abstract.php.

00128     {
00129         return $this->_profile;
00130     }

importXml ( Varien_Simplexml_Element actionNode  ) 

Definition at line 187 of file Abstract.php.

00188     {
00189         foreach ($actionNode->attributes() as $key=>$value) {
00190             $this->setParam($key, (string)$value);
00191         }
00192 
00193         if ($actionNode['use']) {
00194             $container = $this->getProfile()->getContainer((string)$actionNode['use']);
00195         } else {
00196             $this->setParam('class', $this->getClassNameByType((string)$actionNode['type']));
00197             $container = $action->getContainer();
00198         }
00199         $this->setContainer($container);
00200         if ($this->getParam('name')) {
00201             $this->getProfile()->addContainer($this->getParam('name'), $container);
00202         }
00203         foreach ($actionNode->var as $varNode) {
00204             $container->setVar((string)$varNode['name'], (string)$varNode);
00205         }
00206         foreach ($actionNode->action as $actionSubnode) {
00207             $action = $this->addAction();
00208             $action->importXml($actionSubnode);
00209         }
00210 
00211         return $this;
00212     }

run ( array args = array()  ) 

Run current action

Returns:
Mage_Dataflow_Model_Convert_Action_Abstract

Definition at line 219 of file Abstract.php.

00220     {
00221         if ($method = $this->getParam('method')) {
00222 //            print $method;
00223             if (!is_callable(array($this->getContainer(), $method))) {
00224                 $this->getContainer()->addException('Unable to run action method: '.$method, Mage_Dataflow_Model_Convert_Exception::FATAL);
00225             }
00226 
00227 //            printf('<pre>call %s::%s()</pre>', __CLASS__, __FUNCTION__);
00228 //            printf('<pre>call %s::%s()</pre>', get_class($this->getContainer()), $method);
00229 
00230 //            print '<pre>CONTAINER = ';
00231 //            print get_class($this->getContainer());
00232 //            print '</pre>';
00233 
00234             $this->getContainer()->addException('Starting '.get_class($this->getContainer()).' :: '.$method);
00235 
00236             if ($this->getParam('from')) {
00237 //                print '$this->getParam(\'from\') = ' . $this->getParam('from');
00238                 $this->getContainer()->setData($this->getContainer($this->getParam('from'))->getData());
00239             }
00240 
00241 
00242             $this->getContainer()->$method($args);
00243 
00244             if ($this->getParam('to')) {
00245                 $this->getContainer($this->getParam('to'))->setData($this->getContainer()->getData());
00246             }
00247         } else {
00248             $this->addException('No method specified', Mage_Dataflow_Model_Convert_Exception::FATAL);
00249         }
00250         return $this;
00251     }

runActions ( array args = array()  ) 

Definition at line 253 of file Abstract.php.

00254     {
00255         if (empty($this->_actions)) {
00256             return $this;
00257         }
00258         foreach ($this->_actions as $action) {
00259             $action->run($args);
00260         }
00261         return $this;
00262     }

setContainer ( Mage_Dataflow_Model_Convert_Container_Interface container  ) 

Set action's container

Parameters:
Mage_Dataflow_Model_Convert_Container_Interface $container
Returns:
Mage_Dataflow_Model_Convert_Action_Abstract

Definition at line 160 of file Abstract.php.

00161     {
00162         $this->_container = $container;
00163         $this->_container->setProfile($this->getProfile());
00164         $this->_container->setAction($this);
00165         return $this;
00166     }

setParam ( key,
value = null 
)

Set action parameter

Parameters:
string $key
mixed $value
Returns:
Mage_Dataflow_Model_Convert_Action_Abstract

Definition at line 90 of file Abstract.php.

00091     {
00092         if (is_array($key) && is_null($value)) {
00093             $this->_params = $key;
00094         } else {
00095             $this->_params[$key] = $value;
00096         }
00097         return $this;
00098     }

setParams ( params  ) 

Set all action parameters

Parameters:
array $params
Returns:
Mage_Dataflow_Model_Convert_Action_Abstract

Definition at line 116 of file Abstract.php.

00117     {
00118         $this->_params = $params;
00119         return $this;
00120     }

setProfile ( Mage_Dataflow_Model_Convert_Profile_Interface profile  ) 

Set profile instance the action belongs to

Parameters:
Mage_Dataflow_Model_Convert_Profile_Abstract $profile
Returns:
Mage_Dataflow_Model_Convert_Action_Abstract

Definition at line 138 of file Abstract.php.

00139     {
00140         $this->_profile = $profile;
00141         return $this;
00142     }


Member Data Documentation

$_actionDefaultClass = 'Mage_Dataflow_Model_Convert_Action' [protected]

Definition at line 66 of file Abstract.php.

$_actions = array() [protected]

Definition at line 57 of file Abstract.php.

$_container [protected]

Definition at line 64 of file Abstract.php.

$_params [protected]

Definition at line 48 of file Abstract.php.

$_profile [protected]

Definition at line 55 of file Abstract.php.


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

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