RESTful-Drupal / restful

RESTful best practices for Drupal
https://drupal.org/project/restful
419 stars 173 forks source link

Return fields not found in node (but are) #1049

Open naidim opened 5 years ago

naidim commented 5 years ago

Trying to expose the 'metatags' field added to nodes from the Metatag module, which is accessible via node_load and RESTful simply says "The property metatags could not be found in node" even though it exposes just fine via Services or Contentasjson modules. Is there something special in RESTful I'm missing or is it purposely filtering that field?

Here's what I've done to expose the field (and I'm sure its completely wrong, but it works)

protected function publicFields() {
...
  // Expose Metatags
  $public_fields['metatags'] = array(
    'property' => 'nid',
    'process_callbacks' => array(
      array($this, 'getMetatags'),
    )
  );
...
public function getMetatags($value) {
  $node = node_load($value);
  return $node->metatags[$node->language];
}