Posted by ParisLiakos on February 2, 2013 at 12:59am
Project:
Drupal core
Introduced in branch:
8.x Description:
Feeds
Aggregator feeds and feed items are now Content Entities.
Whenever a feed/feed item id needs to be retrieved use $feed->id() and $feed->label() for title.
D7
<?php
// Feeds
$feeds = db_query('SELECT * FROM {aggregator_feed}');
foreach ($feeds as $feed) {
$options[$feed->fid] = $feed->title;
}
// Feed items
$items = db_query('SELECT * FROM {aggregator_item}');
foreach ($items as $item) {
$options[$item->iid] = $item->title;
}
?>D8
<?php
// Feeds
$feeds = entity_load_multiple('aggregator_feed');
foreach ($feeds as $feed) {
$options[$feed->id()] = $feed->label();
}
// Feed items
$items = entity_load_multiple('aggregator_item');
foreach ($items as $item) {
$options[$item->id()] = $item->label();
}
?>- aggregator_save_feed() and aggregator_save_item() have been removed in favor of save() method
D7
<?php
// Feeds
$feed = array(
'title' => $title,
'url' => $feed_url,
'refresh' => '900',
'block' => 5,
);
aggregator_save_feed($feed);
// Feed items
$item = array(
'fid' => $fid,
'timestamp' => $timestamp,
'title' => $title,
'link' => $link,
'author' => $author,
'description' => $description,
'guid' => $guid,
);
aggregator_save_item($item);
?>D8
<?php
// Feeds
$feed = entity_create('aggregator_feed', array(
'title' => $title,
'url' => $feed_url,
'refresh' => 900,
'block' => 5,
));
$feed->save();
// Feed items
$item = entity_create('aggregator_item', array(
'fid' => $fid,
'timestamp' => $timestamp,
'title' => $title,
'link' => $link,
'author' => $author,
'description' => $description,
'guid' => $guid,
));
$item->save();
?>Impacts:
Module developers