You are here

public function RestfulEntityBase::publicFieldsInfo in RESTful 7

Return the properties that should be public.

Return value

array

Throws

\RestfulEntityViewMode

Overrides RestfulInterface::publicFieldsInfo

13 calls to RestfulEntityBase::publicFieldsInfo()
RestfulEntityBaseUser::publicFieldsInfo in plugins/restful/RestfulEntityBaseUser.php
Overrides \RestfulEntityBase::publicFieldsInfo().
RestfulExampleArticlesResource__1_1::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.1/RestfulExampleArticlesResource__1_1.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleArticlesResource__1_5::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.5/RestfulExampleArticlesResource__1_5.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleArticlesResource__1_6::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.6/RestfulExampleArticlesResource__1_6.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleRoleResource::publicFieldsInfo in modules/restful_example/plugins/restful/node/per_role_content/1.0/RestfulExampleRoleResource.class.php
Overrides \RestfulEntityBase::publicFields().

... See full list

14 methods override RestfulEntityBase::publicFieldsInfo()
RestfulEntityBaseUser::publicFieldsInfo in plugins/restful/RestfulEntityBaseUser.php
Overrides \RestfulEntityBase::publicFieldsInfo().
RestfulExampleArticlesResource__1_1::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.1/RestfulExampleArticlesResource__1_1.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleArticlesResource__1_5::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.5/RestfulExampleArticlesResource__1_5.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleArticlesResource__1_6::publicFieldsInfo in modules/restful_example/plugins/restful/node/articles/1.6/RestfulExampleArticlesResource__1_6.class.php
Overrides RestfulExampleArticlesResource::publicFieldsInfo().
RestfulExampleRoleResource::publicFieldsInfo in modules/restful_example/plugins/restful/node/per_role_content/1.0/RestfulExampleRoleResource.class.php
Overrides \RestfulEntityBase::publicFields().

... See full list

File

plugins/restful/RestfulEntityBase.php, line 1216
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

public function publicFieldsInfo() {
  $entity_info = $this
    ->getEntityInfo();
  $id_key = $entity_info['entity keys']['id'];
  $public_fields = array(
    'id' => array(
      'wrapper_method' => 'getIdentifier',
      'wrapper_method_on_entity' => TRUE,
      'property' => $id_key,
      'discovery' => array(
        // Information about the field for human consumption.
        'info' => array(
          'label' => t('ID'),
          'description' => t('Base ID for the entity.'),
        ),
        // Describe the data.
        'data' => array(
          'type' => 'int',
          'read_only' => TRUE,
        ),
      ),
    ),
    'label' => array(
      'wrapper_method' => 'label',
      'wrapper_method_on_entity' => TRUE,
      'discovery' => array(
        // Information about the field for human consumption.
        'info' => array(
          'label' => t('Label'),
          'description' => t('The label of the resource.'),
        ),
        // Describe the data.
        'data' => array(
          'type' => 'string',
        ),
        // Information about the form element.
        'form_element' => array(
          'type' => 'textfield',
          'size' => 255,
        ),
      ),
    ),
    'self' => array(
      'callback' => array(
        $this,
        'getEntitySelf',
      ),
    ),
  );
  if ($view_mode_info = $this
    ->getPluginKey('view_mode')) {
    if (empty($view_mode_info['name'])) {
      throw new \RestfulServerConfigurationException('View mode not found.');
    }
    $view_mode_handler = new \RestfulEntityViewMode($this
      ->getEntityType(), $this
      ->getBundle());
    $public_fields += $view_mode_handler
      ->mapFields($view_mode_info['name'], $view_mode_info['field_map']);
    return $public_fields;
  }
  if (!empty($entity_info['entity keys']['label'])) {
    $public_fields['label']['property'] = $entity_info['entity keys']['label'];
  }
  return $public_fields;
}