public function publicFieldsInfo()
 {
     $public_fields = parent::publicFieldsInfo();
     // Declare common public fields to all the meters so filtering could work.
     $public_fields['timestamp'] = array('property' => 'timestamp');
     // Message short-text, after placeholder replacement
     $public_fields['text'] = array('property' => 'mid', 'process_callbacks' => array(array($this, 'getText')));
     // Message long-text, after placeholder replacement
     $public_fields['longText'] = array('property' => 'mid', 'process_callbacks' => array(array($this, 'getLongText')));
     // Node Id of meter.
     $public_fields['meter'] = array('property' => 'field_meter', 'resource' => array('modbus_meter' => array('name' => 'meters', 'full_view' => FALSE), 'iec_meter' => array('name' => 'meters', 'full_view' => FALSE)));
     $public_fields['meter_account'] = array('property' => 'field_meter_account', 'resource' => array('account' => array('name' => 'accounts', 'full_view' => FALSE)));
     return $public_fields;
 }
 /**
  * {@inheritdoc}
  *
  * Return the basic entity field query for meters, with additional filter
  * that matches 'show-dead-meters' option of the account.
  */
 public function getEntityFieldQuery()
 {
     $query = parent::getEntityFieldQuery();
     $request = $this->getRequest();
     $filter = !empty($request['filter']) ? $request['filter'] : array();
     $meter_account = !empty($filter['account']) ? $filter['account'] : NULL;
     // Make sure there is 'account' filter.
     if (!$meter_account) {
         throw new \RestfulBadRequestException('Please supply filter[account].');
     }
     // Get the account node.
     $wrapper = entity_metadata_wrapper('node', $meter_account);
     $show_inactive_meters = $wrapper->field_show_inactive_meters->value();
     // Add field condition
     if (!$show_inactive_meters) {
         // Account is set not to show dead meters. Add a condition to show
         // only meters with 'has-electricity' == true.
         $query->fieldCondition('field_has_electricity', 'value', TRUE);
     }
     return $query;
 }