trait HostingFieldable in Aegir Objects 7.3
@file The HostingFieldable trait.
Hierarchy
- trait \HostingFieldable
File
- traits/
HostingFieldable.inc, line 6 - The HostingFieldable trait.
View source
trait HostingFieldable {
/**
* Return the target of an entityreference field.
*/
public function getEntityReference($field) {
return $this
->getFieldValueType($field, 'target_id');
}
public function getFieldValueType($field, $type) {
if (isset($this->node->{$field}) && $this->node->{$field}) {
if (isset($this->node->{$field}[$this->node->language])) {
return $this->node->{$field}[$this->node->language][0][$type];
}
else {
return $this->node->{$field}[0][$type];
}
}
}
/**
* Return the target of an entityreference field.
*/
public function setEntityReference($field, $value) {
return $this->node->{$field}[$this->node->language][0] = array(
'target_id' => $value,
'target_type' => 'node',
);
}
/**
* Return the value of a field.
*/
public function getFieldValue($field) {
return $this
->getFieldValueType($field, 'value');
}
/**
* Set the value of a field.
*/
public function setFieldValue($field, $value) {
return $this->node->{$field}[$this->node->language][0]['value'] = $value;
}
/**
* Set the value of a property.
*/
public function setProperty($property, $value) {
return $this->node->{$property} = $value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HostingFieldable:: |
public | function | Return the target of an entityreference field. | |
HostingFieldable:: |
public | function | Return the value of a field. | |
HostingFieldable:: |
public | function | ||
HostingFieldable:: |
public | function | Return the target of an entityreference field. | |
HostingFieldable:: |
public | function | Set the value of a field. | |
HostingFieldable:: |
public | function | Set the value of a property. |