I'm a Drupal procedural programmer new to OOP and enjoying it, so some of the techniques are new to me.
I'm getting a fatal error when I'm calling a standard drupal function from within code called within an object that creates a custom Rule. It appears that it's looking for the function drupal_json_encode_helper on the Action object rather than from where it's supposed to look. But why? And how to I tell it to search within Drupal-land rather than object-land?
I'm on D7 with xautoload and composer, modifying the fluxdropbox module that uses fluxservices to use PSR-0 for external libraries.
"Fatal error: Call to undefined function Drupal\fluxdropbox\Plugin\Rules\Action\drupal_json_encode_helper()"
Here's the code:
<?php
/**
* @file
* Contains MakeNodes.
*/
namespace Drupal\fluxdropbox\Plugin\Rules\Action;
use Drupal\fluxdropbox\Plugin\Service\DropboxAccountInterface;
use Drupal\fluxdropbox\Rules\RulesPluginHandlerBase;
/**
* Action for posting a status message on a page.
*/
class MakeNodes extends RulesPluginHandlerBase implements \RulesActionHandlerInterface {
/**
* Defines the action.
*/
public static function getInfo() {
return static::getInfoDefaults() + array(
'name' => 'fluxdropbox_make_nodes',
'label' => t('Make Nodes from Text Fiels'),
'parameter' => array(
'account' => static::getAccountParameterInfo(),
),
);
}
/**
* Executes the action.
*/
public function execute(DropboxAccountInterface $account) {
//here I build a nice array
file_put_contents(drupal_json_encode_helper($feed_array), $path . '/novel.txt');
}
}
hook_rules_action_info
etc..