2. Возможности модуля Feeds:
● Агрегация данных из разных источников
● Выполнение в фоновом режиме
● Обновление/добавление данных через
определенные промежутки времени
● Feeds API
● Использование GUIDs для связи
● Расширение существуеющих плагинов
● Доступ для загрузки пользователям
● Экспорт/импорт клонирование импортеров
Стандартный набор:
● RSS, CSV, OPML, Sitemap
● HTTP, File upload
● Node, Taxonomy term, User
5. FeedsProcessor:
entityType() - должен возвращать тип сущности
entityInfo() - определение доп. информации сущности
newEntity(FeedsSource $source) - инициализация новой сущности
entityLoad(FeedsSource $source, $entity_id) - загрузка сущности,
если существует с указанным уникальным ключом
entitySave($entity)
entityValidate($entity)
entitySaveAccess($entity)
entityDeleteMultiple($entity_ids)
process(FeedsSource $source, FeedsParserResult $parser_result)
8. json_example_parser.module
function json_example_parser_feeds_plugins() {
$info = array();
$info['JsonExampleParser'] = array(
'name' => 'JSON parser',
'description' => 'Parses custom JSON.',
'handler' => array(
'parent' => 'FeedsParser', // родительский класс от которого наследуем парсер, стандартные
классы Feeds - FeedsFetcher, FeedsParser и FeedsProcessor
'class' => 'JsonExampleParser', // название парсера, должно совпадать с ключем в массиве
'file' => 'JsonExampleParser.inc', // файл класса парсера
'path' => drupal_get_path('module', 'json_example_parser'), // путь к классу парсера
),
);
return $info;
}
function json_example_parser_enable() {
//clear the cache to display in Feeds as available plugin.
cache_clear_all('plugins:feeds:plugins', 'cache');
}