class FilesUpload__1_0 in RESTful 7.2
Class FilesUpload__1_0 @package Drupal\restful_example\Plugin\Resource
Plugin annotation
@Resource(
name = "files_upload:1.0",
resource = "files_upload",
label = "File upload",
description = "A file upload wrapped with RESTful.",
authenticationTypes = TRUE,
dataProvider = {
"entityType": "file",
"options": {
"scheme": "public"
}
},
menuItem = "file-upload",
majorVersion = 1,
minorVersion = 0
)
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\Plugin\resource\FilesUpload__1_0
- class \Drupal\restful\Plugin\resource\ResourceEntity
Expanded class hierarchy of FilesUpload__1_0
1 file declares its use of FilesUpload__1_0
- FilesUploadTest__1_0.php in tests/
modules/ restful_test/ src/ Plugin/ resource/ file/ file_upload_test/ v1/ FilesUploadTest__1_0.php - Contains \Drupal\restful_test\Plugin\resource\file\file_upload_test\v1\FilesUploadTest__1_0.
File
- src/
Plugin/ resource/ FilesUpload__1_0.php, line 33 - Contains \Drupal\restful\Plugin\resource\FilesUpload__1_0
Namespace
Drupal\restful\Plugin\resourceView source
class FilesUpload__1_0 extends ResourceEntity {
/**
* Constructs a FilesUpload__1_0 object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
// Set dynamic options that cannot be set in the annotation.
$plugin_definition = $this
->getPluginDefinition();
$plugin_definition['authenticationOptional'] = (bool) variable_get('restful_file_upload_allow_anonymous_user', FALSE);
// Store the plugin definition.
$this->pluginDefinition = $plugin_definition;
}
/**
* {@inheritdoc}
*
* If "File entity" module exists, determine access by its provided
* permissions otherwise, check if variable is set to allow anonymous users to
* upload. Defaults to authenticated user.
*/
public function access() {
// The getAccount method may return an UnauthorizedException when an
// authenticated user cannot be found. Since this is called from the access
// callback, not from the page callback we need to catch the exception.
try {
$account = $this
->getAccount();
} catch (UnauthorizedException $e) {
// If a user is not found then load the anonymous user to check
// permissions.
$account = drupal_anonymous_user();
}
if (module_exists('file_entity')) {
return user_access('bypass file access', $account) || user_access('create files', $account);
}
return (variable_get('restful_file_upload_allow_anonymous_user', FALSE) || $account->uid) && parent::access();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurablePluginTrait:: |
protected | property | Plugin instance configuration. | |
ConfigurablePluginTrait:: |
public | function | ||
ConfigurablePluginTrait:: |
public | function | ||
ConfigurablePluginTrait:: |
public | function | ||
FilesUpload__1_0:: |
public | function |
If "File entity" module exists, determine access by its provided
permissions otherwise, check if variable is set to allow anonymous users to
upload. Defaults to authenticated user. Overrides Resource:: |
|
FilesUpload__1_0:: |
public | function |
Constructs a FilesUpload__1_0 object. Overrides ResourceEntity:: |
|
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:: |
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 |
Public fields. Overrides Resource:: |
20 |
ResourceEntity:: |
protected | function | Get the public fields with default values based on view mode information. | |
ResourceInterface:: |
constant | The string that separates multiple ids. |