class ResourceFieldReference in RESTful 7.2
Class ResourceFieldReference.
This field type is useful when you have an arbitrary field, that is not an entity reference field, that returns an ID to another resource. This resource field type will allow you to have a field definition with a callback return an ID and use that as a relationship.
This is specially useful when adding a relationship to an entity based resource from a DB query, or vice versa. See an example of this in action in the example resource main:1.8.
If you need to add a reference to entity things like $node->uid, use \Drupal\restful\Plugin\resource\Field\ResourceFieldEntityReference instead.
@package Drupal\restful\Plugin\resource\Field
Hierarchy
- class \Drupal\restful\Plugin\resource\Field\ResourceFieldBase implements ResourceFieldInterface
- class \Drupal\restful\Plugin\resource\Field\ResourceField implements ResourceFieldInterface
- class \Drupal\restful\Plugin\resource\Field\ResourceFieldReference
- class \Drupal\restful\Plugin\resource\Field\ResourceField implements ResourceFieldInterface
Expanded class hierarchy of ResourceFieldReference
File
- src/
Plugin/ resource/ Field/ ResourceFieldReference.php, line 29 - Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldReference.
Namespace
Drupal\restful\Plugin\resource\FieldView source
class ResourceFieldReference extends ResourceField {
/**
* Overrides ResourceField::compoundDocumentId().
*/
public function compoundDocumentId(DataInterpreterInterface $interpreter) {
$collection = parent::compoundDocumentId($interpreter);
if (!$collection instanceof ResourceFieldCollectionInterface) {
return NULL;
}
$id_field = $collection
->getIdField();
if (!$id_field instanceof ResourceFieldInterface) {
return NULL;
}
return $id_field
->render($collection
->getInterpreter());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ResourceField:: |
public | function |
Check access on property by the defined access callbacks. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public | function |
Adds the default values to the definitions array. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public static | function |
Factory. Overrides ResourceFieldInterface:: |
2 |
ResourceField:: |
public static | function | Get the class name to use based on the field definition. | |
ResourceField:: |
public | function |
Gets the cardinality of the wrapped field. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public | function |
Gets the value of a field and applies all process callbacks to it. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public | function |
Gets the value for the field given a data source. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public | function |
Set the cardinality. Overrides ResourceFieldInterface:: |
|
ResourceField:: |
public | function |
Gets the value for the field given a data source. Overrides ResourceFieldInterface:: |
2 |
ResourceField:: |
public | function | Constructor. | 1 |
ResourceFieldBase:: |
protected | property | An array of callbacks to determine if user has access to the property. Note that this callback is on top of the access provided by entity API, and is used for convenience, where for example write operation on a property should be denied only on… | |
ResourceFieldBase:: |
protected | property | A callable callback to get a computed value. The wrapped entity is passed as argument. Defaults To FALSE. The callback function receive as first argument the entity. | |
ResourceFieldBase:: |
protected | property | Holds the field cardinality. | |
ResourceFieldBase:: |
protected | property | The field definition array. | |
ResourceFieldBase:: |
protected | property | A generic array storage. | |
ResourceFieldBase:: |
protected | property | The HTTP methods where this field applies. | |
ResourceFieldBase:: |
protected | property | An array of callbacks to perform on the returned value, or an array with the object and method. | |
ResourceFieldBase:: |
protected | property | The entity property (e.g. "title", "nid"). | |
ResourceFieldBase:: |
protected | property | Information about the field. | |
ResourceFieldBase:: |
protected | property | Contains the public field name. | |
ResourceFieldBase:: |
protected | property | The request object to be used. | |
ResourceFieldBase:: |
protected | property | This property can be assigned only to an entity reference field. Array of restful resources keyed by the target bundle. For example, if the field is referencing a node entity, with "Article" and "Page" bundles, we are able to map… | |
ResourceFieldBase:: |
constant | Return this value from public field access callbacks to allow access. | ||
ResourceFieldBase:: |
constant | Return this value from public field access callbacks to deny access. | ||
ResourceFieldBase:: |
constant | Return this value from public field access callbacks to not affect access. | ||
ResourceFieldBase:: |
public | function |
Add metadata to the field. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function | Basic auto discovery information. | |
ResourceFieldBase:: |
public static | function | Returns the basic discovery information for a given field. | |
ResourceFieldBase:: |
public | function |
Executes the process callbacks. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Gets the original field definition as declared in Resource::publicFields(). Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Add metadata to the field. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Gets the public field info object. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Get the request in the data provider. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Gets the ID of the resource field. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
protected | function | Returns the last array element from the nested namespace array. | |
ResourceFieldBase:: |
final public static | function |
Helper method to determine if an array is numeric. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Checks if the current field is computed. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Gets the public field info object. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Set the request. Overrides ResourceFieldInterface:: |
|
ResourceFieldBase:: |
public | function |
Overrides ResourceFieldInterface:: |
|
ResourceFieldReference:: |
public | function |
Overrides ResourceField::compoundDocumentId(). Overrides ResourceField:: |