- Issue created by @ericgsmith
- 🇳🇱Netherlands MegaChriz
I think that:
- DynamicItem needs to check if the requested field exists on the
$data
array usingarray_key_exists()
; - OpmlItem, SitemapItem and SyndicationItem should return
TRUE
when the requested field is a defined property on the class. For example, SyndicationItem has a property called$author_name
, so that would mean that$item->has('author_name');
is alwaysTRUE
. I think it would need to be done that way because I don't know how else you could distinguishNULL
from "doesn't exist" for these items. I think that class properties that aren't set will just equal toNULL
, or isn't this the case? - BaseItem could already implement
has()
that would check if the class property exists. However, DynamicItem should not returnTRUE
for$item->has('data');
(unless the data array contains an array key called "data").
This would result into at least the following test cases:
- SyndicationItem:
$item->has('author_name');
should returnTRUE
. - SyndicationItem:
$item->has('foo');
should returnFALSE
. - DynamicItem with fields 'foo' and 'bar' set:
$item->has('data');
should returnFALSE
. - DynamicItem with fields 'foo' and 'bar' set:
$item->has('foo');
should returnTRUE
. - DynamicItem with fields 'foo' and 'bar' set:
$item->has('qux');
should returnFALSE
. - DynamicItem with field 'data' set:
$item->has('data');
should returnTRUE
.
Perhaps for OpmlItem and SitemapItem we need similar tests (almost the same) as for SyndicationItem.
- DynamicItem needs to check if the requested field exists on the
- 🇳🇱Netherlands MegaChriz
Related issue that also affects the implementation of item classes: 🐛 Creation of dynamic property Drupal\feeds\Feeds\Item\SyndicationItem::$parent:fid is deprecated Needs work .