class Main__1_1 in RESTful 7.2
Class Main__1_1 @package Drupal\restful_test\Plugin\resource
Plugin annotation
@Resource(
name = "main:1.1",
resource = "main",
label = "Main",
description = "Export the entity test 'main' bundle.",
authenticationOptional = TRUE,
dataProvider = {
"entityType": "entity_test",
"bundles": {
"main"
},
},
majorVersion = 1,
minorVersion = 1
)
Hierarchy
- class \Drupal\restful\Plugin\resource\Resource extends \Drupal\Component\Plugin\PluginBase implements ResourceInterface uses ConfigurablePluginTrait
- class \Drupal\restful\Plugin\resource\ResourceEntity
- class \Drupal\restful_test\Plugin\resource\entity_test\main\v1\Main__1_0 implements ResourceInterface
- class \Drupal\restful_test\Plugin\resource\entity_test\main\v1\Main__1_1 implements ResourceInterface
- class \Drupal\restful_test\Plugin\resource\entity_test\main\v1\Main__1_0 implements ResourceInterface
- class \Drupal\restful\Plugin\resource\ResourceEntity
Expanded class hierarchy of Main__1_1
File
- tests/
modules/ restful_test/ src/ Plugin/ resource/ entity_test/ main/ v1/ Main__1_1.php, line 33 - Contains \Drupal\restful_test\Plugin\resource\entity_test\main\v1\Main__1_1.
Namespace
Drupal\restful_test\Plugin\resource\entity_test\main\v1View source
class Main__1_1 extends Main__1_0 implements ResourceInterface {
/**
* Overrides ResourceEntity::publicFields().
*/
protected function publicFields() {
$public_fields = parent::publicFields();
$public_fields['text_single'] = array(
'property' => 'text_single',
);
$public_fields['text_multiple'] = array(
'property' => 'text_multiple',
'discovery' => array(
'info' => array(
'label' => t('Text multiple'),
'description' => t('This field holds different text inputs.'),
),
'data' => array(
'type' => 'string',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
),
'form_element' => array(
'type' => 'textfield',
'size' => 255,
'placeholder' => t('This is helpful.'),
),
),
);
$public_fields['text_single_processing'] = array(
'property' => 'text_single_processing',
'sub_property' => 'value',
);
$public_fields['text_multiple_processing'] = array(
'property' => 'text_multiple_processing',
'sub_property' => 'value',
);
$public_fields['entity_reference_single'] = array(
'property' => 'entity_reference_single',
'wrapper_method' => 'getIdentifier',
);
$public_fields['entity_reference_multiple'] = array(
'property' => 'entity_reference_multiple',
'wrapper_method' => 'getIdentifier',
);
// Single entity reference field with "resource".
$public_fields['entity_reference_single_resource'] = array(
'property' => 'entity_reference_single',
'resource' => array(
'name' => 'main',
'majorVersion' => 1,
'minorVersion' => 1,
),
);
// Multiple entity reference field with "resource".
$public_fields['entity_reference_multiple_resource'] = array(
'property' => 'entity_reference_multiple',
'resource' => array(
'name' => 'main',
'majorVersion' => 1,
'minorVersion' => 1,
),
);
$public_fields['term_single'] = array(
'property' => 'term_single',
'sub_property' => 'tid',
);
$public_fields['term_multiple'] = array(
'property' => 'term_multiple',
'sub_property' => 'tid',
);
$public_fields['file_single'] = array(
'property' => 'file_single',
'process_callbacks' => array(
array(
$this,
'getFilesId',
),
),
);
$public_fields['file_multiple'] = array(
'property' => 'file_multiple',
'process_callbacks' => array(
array(
$this,
'getFilesId',
),
),
);
$public_fields['image_single'] = array(
'property' => 'image_single',
'process_callbacks' => array(
array(
$this,
'getFilesId',
),
),
);
$public_fields['image_multiple'] = array(
'property' => 'image_multiple',
'process_callbacks' => array(
array(
$this,
'getFilesId',
),
),
);
return $public_fields;
}
/**
* Return the files ID from the multiple files array.
*
* Since by default Entity API does not allow to get the file ID, we extract
* it ourself in this preprocess callback.
*
* @param array $value
* Array of files array as retrieved by the wrapper.
*
* @return int
* Array with file IDs.
*/
public function getFilesId(array $value) {
if (ResourceFieldBase::isArrayNumeric($value)) {
$return = array();
foreach ($value as $file_array) {
$return[] = $this
->getFilesId($file_array);
}
return $return;
}
return empty($value['fid']) ? NULL : $value['fid'];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurablePluginTrait:: |
protected | property | Plugin instance configuration. | |
ConfigurablePluginTrait:: |
public | function | ||
ConfigurablePluginTrait:: |
public | function | ||
ConfigurablePluginTrait:: |
public | function | ||
Main__1_1:: |
public | function | Return the files ID from the multiple files array. | |
Main__1_1:: |
protected | function |
Overrides ResourceEntity::publicFields(). Overrides ResourceEntity:: |
1 |
Resource:: |
protected | property | The authentication manager. | |
Resource:: |
protected | property | The data provider. | |
Resource:: |
protected | property | Indicates if the resource is enabled. | |
Resource:: |
protected | property | The field definition object. | |
Resource:: |
protected | property | The requested path. | |
Resource:: |
protected | property | The current request. | |
Resource:: |
public | function |
Determine if user can access the handler. Overrides ResourceInterface:: |
1 |
Resource:: |
protected | function | Checks access based on the referer header and the allowOrigin setting. | |
Resource:: |
public | function |
Gets the controllers. Overrides ResourceInterface:: |
6 |
Resource:: |
public | function |
Basic implementation for create. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Overrides ConfigurablePluginTrait:: |
|
Resource:: |
public | function |
Disable the resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Discovery controller callback. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Shorthand method to perform a quick DELETE request. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Shorthand method to perform a quick GET request. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Shorthand method to perform a quick PATCH request. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Shorthand method to perform a quick POST request. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Shorthand method to perform a quick PUT request. Overrides ResourceInterface:: |
|
Resource:: |
private | function | ||
Resource:: |
public | function |
Enable the resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Get the user from for request. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Return the controller for a given path. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the controllers for this resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the data provider. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the field definitions. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the path of the resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Get the request object. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the resource machine name. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets the resource name. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Helper method; Get the URL of the resource and query strings. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Return array keyed with the major and minor version of the resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Basic implementation for listing. Overrides ResourceInterface:: |
1 |
Resource:: |
protected | function | Initializes the authentication manager and adds the appropriate providers. | |
Resource:: |
public | function |
Checks if the resource is enabled. Overrides ResourceInterface:: |
|
Resource:: |
protected | function | Adds the Allowed-Origin headers. | |
Resource:: |
public | function |
Controller function that passes the data along and executes right action. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Sets the data provider. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Sets the field definitions. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Sets the path of the resource. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Sets the plugin definition to the provided array. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Sets the request object. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Switches the user back from the original user for the session. Overrides ResourceInterface:: |
1 |
Resource:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Gets a resource URL based on the current version. Overrides ResourceInterface:: |
|
Resource:: |
public | function |
Basic implementation for view. Overrides ResourceInterface:: |
|
ResourceEntity:: |
protected | property | The entity bundles. | |
ResourceEntity:: |
protected | property | The entity type. | |
ResourceEntity:: |
protected | function |
Data provider class. Overrides Resource:: |
3 |
ResourceEntity:: |
public | function |
Data provider factory. Overrides Resource:: |
|
ResourceEntity:: |
public | function | Gets the entity bundle. | |
ResourceEntity:: |
public | function | Get the "self" url. | |
ResourceEntity:: |
public | function | Gets the entity type. | |
ResourceEntity:: |
protected | function |
Get the public fields with the default values applied to them. Overrides Resource:: |
2 |
ResourceEntity:: |
protected | function | Get the public fields with default values based on view mode information. | |
ResourceEntity:: |
public | function |
Constructs a Drupal\Component\Plugin\PluginBase object. Overrides Resource:: |
2 |
ResourceInterface:: |
constant | The string that separates multiple ids. |