Magento Forum

   
I don’t understand why this works (accessing object properties like $foo[’bar’])
 
zburnham
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-07
Westborough, MA
 

protected function _generateAction($node$parent)
    
{
        $method 
= (string)$node['method'];

This is from /code/core/Mage/Core/Layout.php.  $node in this case is an object of class Mage_Core_Model_Layout_Element.

I don’t understand why this works; when I try to do something similar in a test file, I get the error

PHP Fatal error:  Cannot use object of type foo as array

Perhaps I’m missing something here; would someone do me a favor and point out my ignorance, please.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Mage_Core_Model_Layout_Element extends SimpleXMLElement.
It is PHP’s built-in functionality to access node’s attributes in associative array syntax.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zburnham
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-07
Westborough, MA
 

Thanks.  Apparently I need to get in the shed on PHP’s XML functions.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top