Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: 1.7.8
-
Fix Version/s: None
-
Component/s: Zend_Feed
-
Labels:None
-
Tags:
Description
Zend_Feed_Builder currently requires an entry of at least one itunes category if
itunes element is used.
iTunes Store - the main user of these tags - however does not require the category to be set prior
to entering this feed to the podcast store. If category is not set when entering the feed, user
is required to enter the category manually. This manual setting is not allowed should the category
be set already.
Therefore the requirement for category to be set should be optional instead of being required.
The following modifications solve the problem for me:
Zend_Feed_Builder_Header_Itunes:
public function __construct(array $categories)
{
if( !empty($categories) ) {
$this->setCategories($categories);
}
}
Zend_Feed_Builder:
if( isset($data['itunes']['category']) && is_array($data['itunes']['category']) ) {
$itunes = new Yle_Zend_Feed_Builder_Header_Itunes($data['itunes']['category']);
} else {
$itunes = new Yle_Zend_Feed_Builder_Header_Itunes('');
}
The above sample code had an bug when given an empty array as input.
Below is a fixed version:
Zend_Feed_Builder:
if( isset($data['itunes']['category']) &&
!empty($data['itunes']['category']) &&
is_array($data['itunes']['category']) ) { $itunes = new Yle_Zend_Feed_Builder_Header_Itunes($data['itunes']['category']); } else { $itunes = new Yle_Zend_Feed_Builder_Header_Itunes(); }
Zend_Feed_Builder_Header_Itunes:
public function __construct(array $categories = null)
{
if( !empty($categories) ) { $this->setCategories($categories); }
}