Exemplo n.º 1
0
 /**
  * Collects action arguments
  *
  * @param Varien_SimpleXml_Element $node
  * @return array|null
  */
 protected function _collectActionArguments($node)
 {
     if (isset($node['ifconfig']) && !Mage::getStoreConfigFlag((string) $node['ifconfig'])) {
         return null;
     }
     $args = (array) $node->children();
     unset($args['@attributes']);
     foreach ($args as $key => $arg) {
         if ($arg instanceof Mage_Core_Model_Layout_Element) {
             if (isset($arg['helper'])) {
                 $helperName = explode('/', (string) $arg['helper']);
                 $helperMethod = array_pop($helperName);
                 $helperName = implode('/', $helperName);
                 $arg = $arg->asArray();
                 unset($arg['@']);
                 $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
             } else {
                 /**
                  * if there is no helper we hope that this is assoc array
                  */
                 $arr = array();
                 foreach ($arg as $subkey => $value) {
                     $arr[(string) $subkey] = $value->asArray();
                 }
                 if (!empty($arr)) {
                     $args[$key] = $arr;
                 }
             }
         }
     }
     if (isset($node['json'])) {
         $json = explode(' ', (string) $node['json']);
         foreach ($json as $arg) {
             $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
         }
     }
     return $args;
 }