class DynamicItem in Feeds 8.3
Defines an item class for when a parser has a dynamic set of fields.
This should be avoided unless the parser allows dynamic field.
Hierarchy
- class \Drupal\feeds\Feeds\Item\DynamicItem implements ItemInterface
Expanded class hierarchy of DynamicItem
5 files declare their use of DynamicItem
- AfterParseBaseTest.php in tests/
src/ Unit/ EventSubscriber/ AfterParseBaseTest.php - CsvParser.php in src/
Feeds/ Parser/ CsvParser.php - DynamicItemTest.php in tests/
src/ Unit/ Feeds/ Item/ DynamicItemTest.php - FeedRefreshTest.php in tests/
src/ Unit/ Plugin/ QueueWorker/ FeedRefreshTest.php - LazySubscriberTest.php in tests/
src/ Unit/ EventSubscriber/ LazySubscriberTest.php
File
- src/
Feeds/ Item/ DynamicItem.php, line 10
Namespace
Drupal\feeds\Feeds\ItemView source
class DynamicItem implements ItemInterface {
/**
* The field data.
*
* @var array
*/
protected $data = [];
/**
* {@inheritdoc}
*/
public function get($field) {
return isset($this->data[$field]) ? $this->data[$field] : NULL;
}
/**
* {@inheritdoc}
*/
public function set($field, $value) {
$this->data[$field] = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function toArray() {
return $this->data;
}
/**
* {@inheritdoc}
*/
public function fromArray(array $data) {
foreach ($data as $field => $value) {
$this
->set($field, $value);
}
return $this;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DynamicItem:: |
protected | property | The field data. | |
DynamicItem:: |
public | function |
Loads data in from an array. Overrides ItemInterface:: |
|
DynamicItem:: |
public | function |
Returns the value for a target field. Overrides ItemInterface:: |
|
DynamicItem:: |
public | function |
Sets a value for a field. Overrides ItemInterface:: |
|
DynamicItem:: |
public | function |
Converts the item to an array. Overrides ItemInterface:: |