You are here

protected function Articles__1_5::publicFields in RESTful 7.2

Overrides ResourceNode::publicFields().

Overrides ResourceEntity::publicFields

File

modules/restful_example/src/Plugin/resource/node/article/v1/Articles__1_5.php, line 41
Contains \Drupal\restful_example\Plugin\resource\node\article\v1\Articles__1_5.

Class

Articles__1_5
Class Articles__1_5 @package Drupal\restful\Plugin\resource

Namespace

Drupal\restful_example\Plugin\resource\node\article\v1

Code

protected function publicFields() {
  $public_fields = parent::publicFields();
  $public_fields['body'] = array(
    'property' => 'body',
    'sub_property' => 'value',
  );
  $public_fields['tags'] = array(
    'property' => 'field_tags',
    'resource' => array(
      'name' => 'tags',
      'majorVersion' => 1,
      'minorVersion' => 0,
    ),
  );
  $public_fields['image'] = array(
    'property' => 'field_image',
    'process_callbacks' => array(
      array(
        $this,
        'imageProcess',
      ),
    ),
    'image_styles' => array(
      'thumbnail',
      'medium',
      'large',
    ),
  );

  // By checking that the field exists, we allow re-using this class on
  // different tests, where different fields exist.
  if (field_info_field('field_images')) {
    $public_fields['images'] = array(
      'property' => 'field_images',
      'process_callbacks' => array(
        array(
          $this,
          'imageProcess',
        ),
      ),
      'image_styles' => array(
        'thumbnail',
        'medium',
        'large',
      ),
    );
  }
  $public_fields['user'] = array(
    'property' => 'author',
    'resource' => array(
      // The name of the resource to map to.
      'name' => 'users',
      // Determines if the entire resource should appear, or only the ID.
      'fullView' => TRUE,
      'majorVersion' => 1,
      'minorVersion' => 0,
    ),
  );
  $public_fields['static'] = array(
    'callback' => '\\Drupal\\restful_example\\Plugin\\resource\\node\\article\\v1\\Articles__1_5::randomNumber',
  );
  return $public_fields;
}