Commit c54ae0f5 authored by webchick's avatar webchick

Issue #1967106 by larowlan, yched, swentel: FieldInstance::getField() method.

parent c6edf7dd
......@@ -372,20 +372,17 @@ function field_read_instances($conditions = array(), $include_additional = array
continue;
}
// Get data from the field. If the field is marked as deleted, we need to
// get it from the state storage.
$field = entity_load('field_entity', $instance->field_name);
if (empty($field) && $include_deleted && isset($deleted_fields[$instance->field_uuid])) {
$field = new Field($deleted_fields[$instance->field_uuid]);
}
if (empty($field)) {
continue;
}
// Some conditions are checked against the field.
$field = $instance->getField();
// Only keep the instance if it matches all conditions.
foreach ($conditions as $key => $value) {
// Extract the actual value against which the condition is checked.
switch ($key) {
case 'field_name':
$checked_value = $field->id;
break;
case 'field.active':
$checked_value = $field->active;
break;
......
......@@ -31,7 +31,7 @@
* }
* )
*/
class Field extends ConfigEntityBase implements \ArrayAccess {
class Field extends ConfigEntityBase implements \ArrayAccess, \Serializable {
/**
* The maximum length of the field ID (machine name), in characters.
......@@ -597,4 +597,20 @@ public function offsetUnset($offset) {
}
}
/**
* {@inheritdoc}
*/
public function serialize() {
// Only store the definition, not external objects or derived data.
return serialize($this->getExportProperties());
}
/**
* {@inheritdoc}
*/
public function unserialize($serialized) {
$this->__construct(unserialize($serialized));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment