I'm trying to add extra nodes to an atom feed, but don't seem to be able
to produce the results I want so am undoubtedly doing something wrong!
I wonder if anyone could give me a point in the right direction?
What I'm doing is using the Zend_Feed_Builder_Entry class, so that
within my controller I can do something like:
public function atomAction()
{
$atom = Zend_Feed::importBuilder(
new Broadcast_Feed_Builder($this->_getAllParams()
), 'atom');
$atom->send();
}
My Broadcast_Feed_Builder class extends Zend_Feed_Builder_Interface. In
my _createEntries method, I have something like:
private function _createEntries()
{
if (count($this->_items)) {
foreach ($this->_items as $item) {
$link = "{$this->_baseUrl}/view/item/{$item->id}";
$entry = new Broadcast_Feed_Builder_Entry($item->title,
$link, $item->summary);
$entry->setId($link)
->setContent($item->content)
->setFocus('internal')
->addDepartment(array('name' => 'Test department',
'code' => '12345'))
->addCategory(array('term' => 'foobar'))
->addCategory(array('term' => 'barfoo'));
$this->_entries[] = $entry;
}
}
}
My Broadcast_Feed_Builder_Entry class extends Zend_Feed_Builder_Entry
and includes the two methods setFocus and addDepartments, such as:
public function setFocus($focus)
{
$this->offsetSet('focus', $focus);
return $this;
}
public function addDepartment(array $department)
{
if (!$this->offsetExists('department')) {
$departments = array($department);
} else {
$departments = $this->offsetGet('department');
$departments[] = $department;
}
$this->offsetSet('departments', $departments);
return $this;
}
Now, given all of that I would have hoped that I would see an additional
'departments' and 'focus' element, as well as a couple category
elements. However, all I see are the categories. I've also tried
adding my own namespace; I had added
Zend_Feed::registerNamespace('myns', 'http://www.example.com/myns/1.0');
before the call to _createHeader() and _createEntries() in my Builder
and then having myns:focus and myns:department(s), but that didn't help any.
So how should I go about extending things so that I can add in my own
elements?
Thanks for any help you're able to give!
Andy
没有评论:
发表评论