SlideShare a Scribd company logo
1 of 11
Download to read offline
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

第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
Kaz Watanabe
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 

What's hot (20)

Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravel
 
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜 「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
 
Perl5i
Perl5iPerl5i
Perl5i
 
第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
 
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
PHP pod mikroskopom
PHP pod mikroskopomPHP pod mikroskopom
PHP pod mikroskopom
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON API
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
Build your own RESTful API with Laravel
Build your own RESTful API with LaravelBuild your own RESTful API with Laravel
Build your own RESTful API with Laravel
 

Viewers also liked

Ubercart7 views catalog ru
Ubercart7 views catalog ruUbercart7 views catalog ru
Ubercart7 views catalog ru
Andrii Podanenko
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
camp_drupal_ua
 

Viewers also liked (13)

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

Similar to Feeds drupal cafe

Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
Hari K T
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
jsmith92
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
 

Similar to Feeds drupal cafe (20)

Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
Symfony internals [english]
Symfony internals [english]Symfony internals [english]
Symfony internals [english]
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency Injection
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Puppet modules for Fun and Profit
Puppet modules for Fun and ProfitPuppet modules for Fun and Profit
Puppet modules for Fun and Profit
 
Puppet Modules for Fun and Profit
Puppet Modules for Fun and ProfitPuppet Modules for Fun and Profit
Puppet Modules for Fun and Profit
 
Using and reusing CakePHP plugins
Using and reusing CakePHP pluginsUsing and reusing CakePHP plugins
Using and reusing CakePHP plugins
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 

More from Andrii Podanenko

Глобальні навчальні дні друпал
Глобальні навчальні дні друпалГлобальні навчальні дні друпал
Глобальні навчальні дні друпал
Andrii Podanenko
 
Ubercart7 Dynamic properties ru
Ubercart7 Dynamic properties ruUbercart7 Dynamic properties ru
Ubercart7 Dynamic properties ru
Andrii Podanenko
 
Yaremchuk - Drupal CodeLobster
Yaremchuk - Drupal CodeLobsterYaremchuk - Drupal CodeLobster
Yaremchuk - Drupal CodeLobster
Andrii Podanenko
 
Yaremchuk - Корпоративные сайты
Yaremchuk - Корпоративные сайтыYaremchuk - Корпоративные сайты
Yaremchuk - Корпоративные сайты
Andrii Podanenko
 

More from Andrii Podanenko (18)

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

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

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 podarokua@gmail.com http://twitter.com/podarok http://facebook.com/podarok http://drupal.org/user/116002