php - Cannot use object of type Closure as array -
fatal error " cannot use object of type closure array", how fix problem. code using below
function message_broker_example_message_broker_consumers($self_name) { $consumers = array(); // example consumer implemented using closure. $consumers['helloworldtoeveryone'] = array( 'queue' => 'helloworldforall', 'callback' => function($message, \closure $ack) { $message = json_decode($message->body); if ($message->name == 'crash') { throw new invalidmessageexception('invalid name detected!'); } if (function_exists('drush_print')) { drush_print('hello world, ' . $message->name); } else { drupal_set_message(t('hello world, @name.', array('@name' => $message->name))); } $ack(); }, 'invalidmessagehandler' => function($message) { if (function_exists('drush_print')) { drush_print('invalid message handler executed.'); } else { drupal_set_message(t('invalid message handler executed.'), 'warning'); } });
the code snippet drupal message_broker module
Comments
Post a Comment