Skip to main content
Joachim's blog

Main navigation

  • Home
  • About

Breadcrumb

  1. Home

Services, or How I Learned We're All Just Secretly hook_menu()

By joachim, Wed, 10/02/2010 - 23:02

I am now batting nodes, complete with imagefield, between separate instances of Drupal with merriment and glee. For yes, I do have a working beta of Content distribution.

I'm about to quickly write a service to get CCK's content_fields() array from the remote, distributing site, so that the retrieving site can show a UI of possible values for a Views nodereference argument. Try it. It all makes sense once you do.

But I remember a couple of months ago, when Services was a total mystery to me. I installed it, knowing that this was what I needed to achieve this task, but I was baffled by it. What was a Service? And how come I needed a server as well? Surely a service is a kind of server? Argh! And so on.

The penny dropped a few weeks ago, when I suddenly realized that a service is really just another kind of hook_menu() item.

Consider: in hook_menu(), you define which function Drupal should call when it gets an HTTP request at a certain path, say, 'node/1'. And in hook_service(), you define which function Drupal should call when it gets a service method request, in this case via XMLRPC (which is still black magic to me, but with Services module, I don't need to know, because it Just Works). For that matter, in Drush's hook_drush_command(), you define... etc etc. They are all the same!

This has me wondering whether for Drupal 8 we should abstract this out to a general hook_callback(), where we define what function Drupal should call when it receives any kind of external input.

Tags

  • drupal
  • 6.x
  • services
  • 7.x
  • drupal planet
  • content distribution
  • abstraction
  • 8.x

Frequent tags

  • Drupal Code Builder (9)
  • git (7)
  • module builder (6)
  • 6.x (5)
  • drupal commerce (4)
  • Field API (3)
  • patching (3)
  • Drush (3)
  • Composer (3)
  • development (3)
  • Entity API (3)
  • multisite (2)
  • tests (2)
  • Drupal core (2)
  • core (2)
  • issue queue (2)
  • modules (2)
  • roadmap (2)
  • 7.x (2)
  • Rector (2)
  • developer tools (2)
  • wtf (2)
  • contributing code (2)
  • code style (2)
  • contrib module (2)
  • maintaining projects (2)
  • drupal.org (2)
  • debugging (2)
Powered by Drupal