You are here

protected function Bean::setFields in Bean (for Drupal 7) 7

Set the fields from the defaults and plugin This can be called externally via loadUP()

File

includes/bean.core.inc, line 232
Bean classes and plugin interface

Class

Bean
The Bean entity class

Code

protected function setFields() {

  // NOTE: When setFields is called externally $this->data is already unserialized.
  if (!empty($this->plugin) && !empty($this->type)) {
    $values = is_array($this->data) ? $this->data : unserialize($this->data);
    foreach ($this->plugin
      ->values() as $field => $default) {
      $this->{$field} = isset($values[$field]) ? $values[$field] : $default;
    }
  }
  return $this;
}