An example that was requested at Linux Fest Northwest 2012.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

mikeytown2’s picture

mikeytown2’s picture

Allows for syntax this this

$args = array(
  array(
    'type' => 'function',
    'call' => 'drupal_bootstrap',
    'args' => array(DRUPAL_BOOTSTRAP_FULL),
    'return' => '',
  ),
  array(
    'type' => 'function',
    'call' => 'db_query',
    'args' => array('SELECT MAX(wid) FROM {watchdog}'),
  ),
  array(
    'type' => 'function',
    'call' => 'db_result',
    'args' => array('last' => NULL),
  ),
  array(
    'type' => 'function',
    'call' => 'print_r',
    'args' => array('last' => NULL),
    'printed' => '',
  ),
);
$args = array(
  array(
    'type' => 'function',
    'call' => 'db_select',
    'args' => array('watchdog', 'w',),

  ),
  array(
    'type' => 'method',
    'call' => 'fields',
    'args' => array('w', array('wid')),
  ),
  array(
    'type' => 'method',
    'call' => 'orderBy',
    'args' => array('wid', 'DESC'),
  ),
  array(
    'type' => 'method',
    'call' => 'range',
    'args' => array(999, 1),
  ),
  array(
    'type' => 'method',
    'call' => 'execute',
    'args' => array(),
  ),
  array(
    'type' => 'method',
    'call' => 'fetchField',
    'args' => array(),
    'return' => '',
  ),
);
mikeytown2’s picture

Following patch has been committed. Now I need to add it into the readme.

mikeytown2’s picture

hass’s picture

Would be helpful to understand why we need this with some concrete examples... I'm currently asking me about the use case...

mikeytown2’s picture

The callback endpoint can now be done at database level bootstrap (full bootstrap currently). Copy httprl_caller.php to root dir... still need to workout some of the details.

Options this gives us:
- Running simple code no longer requires a full bootstrap (big speed improvement).
- Simple multi-step operations no long need a function wrapper.
- Include a file and run a function from it. Callbacks no longer need to be done in .module files.
- We can choose to bootstrap to a higher level and run code.

mikeytown2’s picture

Thinking about this more and I think having the RPC callback be configurable so it can load from a file or hook boot is the best option. Having it backwards compatible is possible so I don't need a 2.x version now that I think about it.
#1558456: Create hook_boot endpoint

mikeytown2’s picture

decided to scrap httprl_caller.php and go with hook_boot for faster execution times. Patch for readme has been committed.

mikeytown2’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.