class CerEntityReferenceField in Corresponding Entity References 7.3
@file Contains the CER plugin for Entity Reference fields.
Hierarchy
- class \FieldInstance
- class \CerField
- class \CerEntityReferenceField
- class \CerField
Expanded class hierarchy of CerEntityReferenceField
2 string references to 'CerEntityReferenceField'
- cer_cer_fields in ./
cer.cer.inc - Implements hook_cer_fields().
- hook_cer_fields in ./
cer.api.php - In order to create relationships between reference fields, CER needs to know about what reference fields are available, and how to handle them, which is what this hook is for. It should always return an array, even if there are no fields to expose.…
File
- includes/
fields/ entity_reference.inc, line 8 - Contains the CER plugin for Entity Reference fields.
View source
class CerEntityReferenceField extends CerField {
/**
* Implements CerField::getTargetType().
*/
public function getTargetType() {
return $this->settings['target_type'];
}
/**
* @override CerField::getTargetBundles().
*/
public function getTargetBundles() {
$bundles = array();
// If the reference field is using a view, load the view and see if it's filtering by the entity
// type's bundle filter. If it is, the filter values are the target bundles. Otherwise,
// assume that all bundles can be referenced.
//
// @todo Support contextual filters?
//
// NOTE: Selection handlers (i.e., $field['settings']['handler']) are plugins owned by
// Entity Reference. There is no method defined to get an array of referenceable
// bundles, but hopefully, if CER gains enough traction in the community, such a
// method can be added to the EntityReference_SelectionHandler interface. This
// function could then be deprecated, which would be a more flexible, future-proof
// method of finding a field's target bundles.
//
if ($this->settings['handler'] == 'views') {
$view = views_get_view($this->settings['handler_settings']['view']['view_name']);
$view
->set_display($this->settings['handler_settings']['view']['display_name']);
$info = entity_get_info($this
->getTargetType());
if (isset($info['entity keys']['bundle'])) {
$handler = $view->display_handler
->get_handler('filter', $info['entity keys']['bundle']);
if ($handler) {
$bundles = $handler->value;
}
}
}
else {
$bundles = $this->settings['handler_settings']['target_bundles'];
}
return $bundles ? $bundles : parent::getTargetBundles();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CerEntityReferenceField:: |
public | function |
@override CerField::getTargetBundles(). Overrides CerField:: |
|
CerEntityReferenceField:: |
public | function |
Implements CerField::getTargetType(). Overrides CerField:: |
|
CerField:: |
public | property | ||
CerField:: |
protected | property | The plugin definition. | |
CerField:: |
protected | property | ||
CerField:: |
public | function | Returns a CerFieldHandler subclass instance for the given entity. | |
CerField:: |
public | function |
Overridden. Overrides FieldInstance:: |
|
CerField:: |
public static | function | Returns a single field plugin instance, by its identifier. All plugin instances are statically cached. | |
CerField:: |
public static | function | Returns information about a particular field plugin by its identifier, or all available plugins (i.e., defined by hook_cer_fields()) if no identifier is given. The aggregated result of hook_cer_fields() is statically cached. | |
CerField:: |
public | function |
Overridden. Overrides FieldInstance:: |
|
CerField:: |
public | function |
Constructor. Pretty self-explanatory! Overrides FieldInstance:: |
1 |
FieldInstance:: |
public | property | The instance bundle. | |
FieldInstance:: |
public | property | The human-readable label of the instance's bundle. | |
FieldInstance:: |
public | property | The cardinality (maximum values) the field supports, or FIELD_CARDINALITY_UNLIMITED. | |
FieldInstance:: |
protected | property | The child of this instance, if any. | |
FieldInstance:: |
public | property | The instance's entity type. | |
FieldInstance:: |
public | property | The human-readable label of the instance's entity type. | |
FieldInstance:: |
public | property | Whether or not this instance's entity type supports bundles. | |
FieldInstance:: |
public | property | The instance's label. | |
FieldInstance:: |
public | property | The field's machine name. | |
FieldInstance:: |
protected | property | The parent of this instance, if any. | |
FieldInstance:: |
public | function | Get or set the child of this field instance. | |
FieldInstance:: |
public | function | Get or set the parent of this field instance. | |
FieldInstance:: |
public | function |