SlideShare a Scribd company logo
Drupal Feeds

   Andriy Podanenko aka @podarok
    http://drupal.org/user/116002
    Kyiv Drupal Cafe`


            feeds developer keynotes


     08.09.2011         Kyiv Drupal Cafe`
POI

   FeedsSource extends FeedsConfigurable
    FeedsSource::import

   Plugins (FeedsFetcher, FeedsParser,
    FeedsProcessor)
   Hooks
   Mappings
    hook_feeds_processor_targets_alter()
    hook_feeds_parser_sources_alter()



       08.09.2011               Kyiv Drupal Cafe`
Manual process
startImport()
 $config = $this->importer->getConfig();
  if ($config['process_in_background']) {
    $this->startBackgroundJob('import');
  }
  else {
    $this->startBatchAPIJob(t('Importing'), 'import'); //method
  }
}
 function startBatchAPIJob(){
 $batch = array(
      'title' => $title,
      'operations' => array(
        array('feeds_batch', array($method, $this->id, $this->feed_nid)),
      ),
    );
    batch_set($batch);
  }

     08.09.2011                  Kyiv Drupal Cafe`
Manual process
    feeds_batch()

   function feeds_batch($method, $importer_id, $feed_nid = 0, &$context) {
  $context['finished'] = FEEDS_BATCH_COMPLETE;
  try {
 // main work doing here
    $context['finished'] = feeds_source($importer_id, $feed_nid)->$method();
  }
  catch (Exception $e) {
    drupal_set_message($e->getMessage(), 'error');
  }
}




        08.09.2011               Kyiv Drupal Cafe`
FeedsSource::import
$this->acquireLock();
 try {
     // Fetch.
     if (empty($this->fetcher_result) || FEEDS_BATCH_COMPLETE == $this-
>progressParsing()) {
       $this->fetcher_result = $this->importer->fetcher->fetch($this);
//….
     }

   // Parse.
   $parser_result = $this->importer->parser->parse($this, $this->fetcher_result);
   module_invoke_all('feeds_after_parse', $this, $parser_result);

   // Process.
   $this->importer->processor->process($this, $parser_result);
  }
  catch (Exception $e) {
// ….
  }
  $this->releaseLock();

     08.09.2011                     Kyiv Drupal Cafe`
Feeds hooks
function feeds_hook_info() {
  $hooks = array(
    'feeds_after_parse',
    'feeds_after_import',
    'feeds_after_clear',
    'feeds_processor_targets_alter',
    'feeds_parser_sources_alter',
  );
 08.09.2011    Kyiv Drupal Cafe`
Feeds plugins hook_feeds_plugins()
 function ofeeds_feeds_plugins() {
  $info = array();
  $info['OpenERP_Fetcher'] = array(
    'name' => 'OpenERP Fetcher',
    'description' => 'Fetches OpenERP objects from Models.',
    'help' => 'Fetches OpenERP objects from Models. Additional help will be
in a feature',
    'handler' => array(
      'parent' => 'FeedsFetcher',
      'class' => 'OpenERP_Fetcher',
      'file' => 'OpenERP_Fetcher.inc',
      'path' => drupal_get_path('module', 'ofeeds') . '/fetchers',
// Feeds will look for OpenERP_Fetcher.inc in the ofeeds/fetchers directory.
      ),
    );

    return $info;
}
           08.09.2011                 Kyiv Drupal Cafe`
Feeds plugins
●class FeedsPlugin extends FeedsConfigurable implements
FeedsSourceInterface
 methods: save, sourceForm, configForm, loadMappers...

FeedsFetcher extends FeedsPlugin
●

methods: clear, fetch...

FeedsParser extends FeedsPlugin
●

methods: parse, clear...

●FeedsProcessor extends FeedsPlugin
 methods: process, entityType, newEntity, entityLoad,
entitySave, entityDeleteMultiple


     08.09.2011           Kyiv Drupal Cafe`
Feeds plugins forms
● configForm
 // forms displayed at feeds instance settings tab (admin level)
 FE: OpenERP_Fetcher::configForm($fs) – select model,
setting for limiting count of fetched data etc.
 Exportable as config array !!! (via import export clone)

// configFormSubmit,configFormValidate

● sourceForm
 // forms displayed at /import/$feeds_instance page and at
content type creation forms (user level)
 FE: FeedsFileFetcher::sourceForm($sc) – upload file form,
form for listing already uploaded files etc.

// sourceFormValidate, sourceFormSubmit
      08.09.2011               Kyiv Drupal Cafe`
Feeds tricks
    function ofeeds_ctools_plugin_api($owner, $api) {
      if ($owner == 'feeds' && $api == 'plugins') {
        return array('version' => 1);
      }
    }

    function ofeeds_enable() {
      //clear the cache to display in Feeds as available plugin.
      cache_clear_all('plugins:feeds:plugins', 'cache');
    }

    // Do not use variable_set as instances config !!!



                                       
Thanks

    Andriy Podanenko @podarok

    podarokua@gmail.com
    http://twitter.com/podarok
    http://facebook.com/podarok
    http://drupal.org/user/116002




                          

More Related Content

What's hot (20)

PDF
Codeigniter : Custom Routing - Manipulate Uri
Abdul Malik Ikhsan
 
PDF
Add loop shortcode
Peter Baylies
 
PDF
Symfony2 - WebExpo 2010
Fabien Potencier
 
PDF
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
PDF
The Origin of Lithium
Nate Abele
 
KEY
Lithium Best
Richard McIntyre
 
PDF
Blog Hacks 2011
Yusuke Wada
 
PPTX
16.mysql stored procedures in laravel
Razvan Raducanu, PhD
 
PDF
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
Makoto Kaga
 
ODP
Perl5i
Marcos Rebelo
 
KEY
第49回Php勉強会@関東 Datasource
Kaz Watanabe
 
PPTX
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
PDF
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
Yusuke Wada
 
PDF
PHP and Rich Internet Applications
elliando dias
 
PDF
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 
ODP
PHP pod mikroskopom
Saša Stamenković
 
PPTX
Looping the Loop with SPL Iterators
Mark Baker
 
PDF
Introduction to the Pods JSON API
podsframework
 
PDF
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
PDF
Build your own RESTful API with Laravel
Francisco Carvalho
 
Codeigniter : Custom Routing - Manipulate Uri
Abdul Malik Ikhsan
 
Add loop shortcode
Peter Baylies
 
Symfony2 - WebExpo 2010
Fabien Potencier
 
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
The Origin of Lithium
Nate Abele
 
Lithium Best
Richard McIntyre
 
Blog Hacks 2011
Yusuke Wada
 
16.mysql stored procedures in laravel
Razvan Raducanu, PhD
 
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
Makoto Kaga
 
第49回Php勉強会@関東 Datasource
Kaz Watanabe
 
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
Yusuke Wada
 
PHP and Rich Internet Applications
elliando dias
 
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 
PHP pod mikroskopom
Saša Stamenković
 
Looping the Loop with SPL Iterators
Mark Baker
 
Introduction to the Pods JSON API
podsframework
 
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
Build your own RESTful API with Laravel
Francisco Carvalho
 

Viewers also liked (13)

PDF
Ubercart7 views catalog ru
Andrii Podanenko
 
PDF
Drupal Optimization
Andrii Podanenko
 
PPTX
Drupal 8 configuration development flow
Andrii Podanenko
 
PDF
Docker SQL Continuous Integration Flow
Andrii Podanenko
 
PDF
Drupal codesprint kyiv drupal cafe 07.02.2013
Andrii Podanenko
 
PDF
Do + ldo for developers(full)
Andrii Podanenko
 
PDF
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
camp_drupal_ua
 
PDF
Live deployment, ci, drupal
Andrii Podanenko
 
PDF
Drupal contrib module maintaining
Andrii Podanenko
 
PDF
Start using vagrant now!
Andrii Podanenko
 
PPTX
Drupal Continuous Integration Workflow
Andrii Podanenko
 
PPTX
природна і економна дорожня карта для переходу команди розробки на тест центр...
Andrii Podanenko
 
PPTX
MoldCamp - multidimentional testing workflow. CIBox.
Andrii Podanenko
 
Ubercart7 views catalog ru
Andrii Podanenko
 
Drupal Optimization
Andrii Podanenko
 
Drupal 8 configuration development flow
Andrii Podanenko
 
Docker SQL Continuous Integration Flow
Andrii Podanenko
 
Drupal codesprint kyiv drupal cafe 07.02.2013
Andrii Podanenko
 
Do + ldo for developers(full)
Andrii Podanenko
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
camp_drupal_ua
 
Live deployment, ci, drupal
Andrii Podanenko
 
Drupal contrib module maintaining
Andrii Podanenko
 
Start using vagrant now!
Andrii Podanenko
 
Drupal Continuous Integration Workflow
Andrii Podanenko
 
природна і економна дорожня карта для переходу команди розробки на тест центр...
Andrii Podanenko
 
MoldCamp - multidimentional testing workflow. CIBox.
Andrii Podanenko
 
Ad

Similar to Feeds drupal cafe (20)

ODP
Aura Project for PHP
Hari K T
 
PDF
Symfony internals [english]
Raul Fraile
 
PDF
Drupal 8 Services And Dependency Injection
Philip Norton
 
PDF
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PDF
SPL: The Missing Link in Development
jsmith92
 
PDF
Apostrophe
tompunk
 
ODP
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
PDF
Unit testing after Zend Framework 1.8
Michelangelo van Dam
 
PDF
Puppet modules for Fun and Profit
Alessandro Franceschi
 
PDF
Puppet Modules for Fun and Profit
Puppet
 
PDF
Using and reusing CakePHP plugins
Pierre MARTIN
 
PDF
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
PDF
Building Lithium Apps
Nate Abele
 
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
PDF
Doctrine For Beginners
Jonathan Wage
 
PDF
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
KEY
Phpne august-2012-symfony-components-friends
Michael Peacock
 
PDF
Advanced symfony Techniques
Kris Wallsmith
 
PDF
Unittests für Dummies
Lars Jankowfsky
 
PDF
PHP 5.3 Overview
jsmith92
 
Aura Project for PHP
Hari K T
 
Symfony internals [english]
Raul Fraile
 
Drupal 8 Services And Dependency Injection
Philip Norton
 
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
SPL: The Missing Link in Development
jsmith92
 
Apostrophe
tompunk
 
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
Unit testing after Zend Framework 1.8
Michelangelo van Dam
 
Puppet modules for Fun and Profit
Alessandro Franceschi
 
Puppet Modules for Fun and Profit
Puppet
 
Using and reusing CakePHP plugins
Pierre MARTIN
 
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Building Lithium Apps
Nate Abele
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
Doctrine For Beginners
Jonathan Wage
 
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
Phpne august-2012-symfony-components-friends
Michael Peacock
 
Advanced symfony Techniques
Kris Wallsmith
 
Unittests für Dummies
Lars Jankowfsky
 
PHP 5.3 Overview
jsmith92
 
Ad

More from Andrii Podanenko (18)

PDF
Глобальні навчальні дні друпал
Andrii Podanenko
 
PDF
Головні Принципи Автоматизації
Andrii Podanenko
 
PDF
Drupal 8 DevOps . Profile and SQL flows.
Andrii Podanenko
 
PDF
CIbox - OpenSource solution for making your #devops better
Andrii Podanenko
 
PDF
DrupalCon Los Angeles - Continuous Integration Toolbox
Andrii Podanenko
 
PDF
Сейчас самое время...ЖИТЬ!
Andrii Podanenko
 
PDF
Drupal 8 what to wait from
Andrii Podanenko
 
PDF
Диалоговый интенсив 2012 карпаты
Andrii Podanenko
 
PDF
психолог в социальных медиа
Andrii Podanenko
 
PDF
Ubercart7 Dynamic properties ru
Andrii Podanenko
 
ODP
Ubercart 7 ru
Andrii Podanenko
 
PDF
Drupal 7 database api
Andrii Podanenko
 
PDF
Yaremchuk - Drupal CodeLobster
Andrii Podanenko
 
PDF
Yaremchuk - Корпоративные сайты
Andrii Podanenko
 
PDF
управление проектами отношение к клиенту
Andrii Podanenko
 
PDF
Друпал - стандартні модулі
Andrii Podanenko
 
PDF
Друпал Drush
Andrii Podanenko
 
PPT
Drupal Migrate
Andrii Podanenko
 
Глобальні навчальні дні друпал
Andrii Podanenko
 
Головні Принципи Автоматизації
Andrii Podanenko
 
Drupal 8 DevOps . Profile and SQL flows.
Andrii Podanenko
 
CIbox - OpenSource solution for making your #devops better
Andrii Podanenko
 
DrupalCon Los Angeles - Continuous Integration Toolbox
Andrii Podanenko
 
Сейчас самое время...ЖИТЬ!
Andrii Podanenko
 
Drupal 8 what to wait from
Andrii Podanenko
 
Диалоговый интенсив 2012 карпаты
Andrii Podanenko
 
психолог в социальных медиа
Andrii Podanenko
 
Ubercart7 Dynamic properties ru
Andrii Podanenko
 
Ubercart 7 ru
Andrii Podanenko
 
Drupal 7 database api
Andrii Podanenko
 
Yaremchuk - Drupal CodeLobster
Andrii Podanenko
 
Yaremchuk - Корпоративные сайты
Andrii Podanenko
 
управление проектами отношение к клиенту
Andrii Podanenko
 
Друпал - стандартні модулі
Andrii Podanenko
 
Друпал Drush
Andrii Podanenko
 
Drupal Migrate
Andrii Podanenko
 

Recently uploaded (20)

PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Feeds drupal cafe

  • 1. Drupal Feeds  Andriy Podanenko aka @podarok http://drupal.org/user/116002 Kyiv Drupal Cafe` feeds developer keynotes 08.09.2011 Kyiv Drupal Cafe`
  • 2. POI  FeedsSource extends FeedsConfigurable FeedsSource::import  Plugins (FeedsFetcher, FeedsParser, FeedsProcessor)  Hooks  Mappings hook_feeds_processor_targets_alter() hook_feeds_parser_sources_alter() 08.09.2011 Kyiv Drupal Cafe`
  • 3. Manual process startImport() $config = $this->importer->getConfig(); if ($config['process_in_background']) { $this->startBackgroundJob('import'); } else { $this->startBatchAPIJob(t('Importing'), 'import'); //method } } function startBatchAPIJob(){ $batch = array( 'title' => $title, 'operations' => array( array('feeds_batch', array($method, $this->id, $this->feed_nid)), ), ); batch_set($batch); } 08.09.2011 Kyiv Drupal Cafe`
  • 4. Manual process feeds_batch() function feeds_batch($method, $importer_id, $feed_nid = 0, &$context) { $context['finished'] = FEEDS_BATCH_COMPLETE; try { // main work doing here $context['finished'] = feeds_source($importer_id, $feed_nid)->$method(); } catch (Exception $e) { drupal_set_message($e->getMessage(), 'error'); } } 08.09.2011 Kyiv Drupal Cafe`
  • 5. FeedsSource::import $this->acquireLock(); try { // Fetch. if (empty($this->fetcher_result) || FEEDS_BATCH_COMPLETE == $this- >progressParsing()) { $this->fetcher_result = $this->importer->fetcher->fetch($this); //…. } // Parse. $parser_result = $this->importer->parser->parse($this, $this->fetcher_result); module_invoke_all('feeds_after_parse', $this, $parser_result); // Process. $this->importer->processor->process($this, $parser_result); } catch (Exception $e) { // …. } $this->releaseLock(); 08.09.2011 Kyiv Drupal Cafe`
  • 6. Feeds hooks function feeds_hook_info() { $hooks = array( 'feeds_after_parse', 'feeds_after_import', 'feeds_after_clear', 'feeds_processor_targets_alter', 'feeds_parser_sources_alter', ); 08.09.2011 Kyiv Drupal Cafe`
  • 7. Feeds plugins hook_feeds_plugins() function ofeeds_feeds_plugins() { $info = array(); $info['OpenERP_Fetcher'] = array( 'name' => 'OpenERP Fetcher', 'description' => 'Fetches OpenERP objects from Models.', 'help' => 'Fetches OpenERP objects from Models. Additional help will be in a feature', 'handler' => array( 'parent' => 'FeedsFetcher', 'class' => 'OpenERP_Fetcher', 'file' => 'OpenERP_Fetcher.inc', 'path' => drupal_get_path('module', 'ofeeds') . '/fetchers', // Feeds will look for OpenERP_Fetcher.inc in the ofeeds/fetchers directory. ), ); return $info; } 08.09.2011 Kyiv Drupal Cafe`
  • 8. Feeds plugins ●class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInterface methods: save, sourceForm, configForm, loadMappers... FeedsFetcher extends FeedsPlugin ● methods: clear, fetch... FeedsParser extends FeedsPlugin ● methods: parse, clear... ●FeedsProcessor extends FeedsPlugin methods: process, entityType, newEntity, entityLoad, entitySave, entityDeleteMultiple 08.09.2011 Kyiv Drupal Cafe`
  • 9. Feeds plugins forms ● configForm // forms displayed at feeds instance settings tab (admin level) FE: OpenERP_Fetcher::configForm($fs) – select model, setting for limiting count of fetched data etc. Exportable as config array !!! (via import export clone) // configFormSubmit,configFormValidate ● sourceForm // forms displayed at /import/$feeds_instance page and at content type creation forms (user level) FE: FeedsFileFetcher::sourceForm($sc) – upload file form, form for listing already uploaded files etc. // sourceFormValidate, sourceFormSubmit 08.09.2011 Kyiv Drupal Cafe`
  • 10. Feeds tricks function ofeeds_ctools_plugin_api($owner, $api) { if ($owner == 'feeds' && $api == 'plugins') { return array('version' => 1); } } function ofeeds_enable() { //clear the cache to display in Feeds as available plugin. cache_clear_all('plugins:feeds:plugins', 'cache'); } // Do not use variable_set as instances config !!!    
  • 11. Thanks Andriy Podanenko @podarok [email protected] http://twitter.com/podarok http://facebook.com/podarok http://drupal.org/user/116002