• Save
Drupal course - batch API
Upcoming SlideShare
Loading in...5
×
 

Drupal course - batch API

on

  • 717 views

 

Statistics

Views

Total Views
717
Views on SlideShare
717
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Drupal course - batch API Drupal course - batch API Presentation Transcript

  • Batch API Dániel Kalmár March 28, 2013
  • What is batch API?
  • What is batch API?● Batch (execution of a series of “jobs”)● Application Programming Interface● Avoid PHP timeout● Spread out the processing over several page requests● Feedback for users (progress bar)● Cannot use in cron jobs View slide
  • When can batch API be useful?● designed to integrate with the Form API workflow● can be used by non-Form API scripts (update, page callbacks)● site install (module install)● bulk operations (nodes, users)● search API (indexing) View slide
  • Functions● batch_get()● batch_process()● batch_set()● hook_batch_alter()● _batch_populate_queue()● _batch_queue()
  • How does it work?
  • Configuration
  • Process● set batch operation● execute batch operation (only need outside of a form submit handler)
  • Operations● $context● Set the starting values
  • Operations● update the values in each steps
  • Operations● check if all the steps have been executed
  • Operations
  • “Finished” callback
  • Cron queue
  • What is cron queue?● cron● hooks● queue API● limit the processing time of a queue per cron run
  • When can cron queue be useful?● processing large amounts of data in cron● bulk operations (nodes, users)● regular newsletter sending
  • How does it work?
  • Define a queue● Implement hook_cron_queue_info()
  • Load the queue● Loading items in the queue in hook_cron()
  • Process a queue item● worker callback deals with the individual queue items
  • Questions?