You are here

public function TestArticles__1_2::publicFields in RESTful 7.2

Overrides ResourceEntity::publicFields().

Overrides ResourceEntity::publicFields

File

tests/modules/restful_test/src/Plugin/resource/node/test_article/v1/TestArticles__1_2.php, line 42
Contains \Drupal\restful_test\Plugin\resource\node\test_article\v1\TestArticles__1_2.

Class

TestArticles__1_2
Class TestArticles @package Drupal\restful\Plugin\resource

Namespace

Drupal\restful_test\Plugin\resource\node\test_article\v1

Code

public function publicFields() {
  $public_fields = parent::publicFields();
  $public_fields['body'] = array(
    'property' => 'body',
    'sub_property' => 'value',
  );

  // By checking that the field exists, we allow re-using this class on
  // different tests, where different fields exist.
  if (field_info_field('entity_reference_single')) {
    $public_fields['entity_reference_single'] = array(
      'property' => 'entity_reference_single',
      'resource' => array(
        'name' => 'test_articles',
        'majorVersion' => 1,
        'minorVersion' => 2,
      ),
    );
  }
  if (field_info_field('entity_reference_multiple')) {
    $public_fields['entity_reference_multiple'] = array(
      'property' => 'entity_reference_multiple',
      'resource' => array(
        'name' => 'test_articles',
        'majorVersion' => 1,
        'minorVersion' => 2,
      ),
    );
  }
  if (field_info_field('integer_single')) {
    $public_fields['integer_single'] = array(
      'property' => 'integer_single',
    );
  }
  if (field_info_field('integer_multiple')) {
    $public_fields['integer_multiple'] = array(
      'property' => 'integer_multiple',
    );
  }
  if (variable_get('restful_test_reference_simple')) {
    $public_fields['user'] = array(
      'property' => 'author',
    );
    if (variable_get('restful_test_reference_resource')) {
      $public_fields['user']['resource'] = array(
        'name' => 'users',
        'majorVersion' => 1,
        'minorVersion' => 0,
      );
    }
  }
  return $public_fields;
}