Zend Framework

Cannot use magic method __get to return custom namespace element 'content'

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Not an Issue
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Zend_Feed
  • Labels:
    None

Description

If you have a feed with a custom namespace element named 'content' you cannot use the magic method __get.

For example, suppose we have a custom namespace 'media' (Used by Yahoo Media RSS Module http://search.yahoo.com/mrss), you might have a feed that partially looks like this:

<item>
   <media:content url="http://www.example.com/content" />
   <media:player url="http://www.example.com/player" />
</item>

If you consume the feed, you can then do something like this:

foreach($channel as $item){

    echo $item->content['url']; //This fails. Outputs nothing.
			
    echo $item->__get('media:content')->getDOM()->getAttribute('url')); // This will work. Outputs 'http://www.example.com/content"

    echo $item->player['url']; // This will work. Outputs 'http://www.example.com/player"
							
}

Activity

Hide
Thomas Weidner added a comment -

Assigned to right component

Show
Thomas Weidner added a comment - Assigned to right component
Hide
Pádraic Brady added a comment -

The content property and method are treated differently under the assumption you mean the actual content element (default namespace). The alternative access methods using the media namespace are therefore the correct access method.

Show
Pádraic Brady added a comment - The content property and method are treated differently under the assumption you mean the actual content element (default namespace). The alternative access methods using the media namespace are therefore the correct access method.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: