You are here

class HostingNode in Aegir Objects 7.3

@file The HostingNode class.

Hierarchy

Expanded class hierarchy of HostingNode

File

classes/HostingNode.inc, line 6
The HostingNode class.

View source
class HostingNode {
  use HostingFieldable;

  // The node object.
  protected $node = FALSE;

  // Fields to format in line with Aegir standards.
  protected $info_fields = [];
  function __construct($node) {
    $this->node = $node;
  }
  public function getNid() {
    return $this->node->nid;
  }
  public function getTitle() {
    return $this->node->title;
  }
  public function getLanguage() {
    return $this->node->language;
  }
  public function getNode() {
    return $this->node;
  }

  /**
   * Alter the display of a node.
   */
  public function nodeView() {
    foreach ($this
      ->getInfoFields() as $field) {
      $this
        ->fixNodeFieldDisplay($field);
    }
  }
  protected function getInfoFields() {
    return $this->info_fields;
  }

  /**
   * Display a field as an Aegir-themed 'info' item.
   */
  public function fixNodeFieldDisplay($field) {
    if (isset($this->node->content[$field])) {
      $this->node->content['info'][$field] = array(
        '#type' => 'item',
        '#title' => $this->node->content[$field]['#title'],
        '#markup' => $this->node->content[$field][0]['#markup'],
      );
      unset($this->node->content[$field]);
    }
  }

  /**
   * Save the node.
   */
  public function save() {
    $this->node = node_submit($this->node);
    node_save($this->node);
    return $this->node->nid;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HostingFieldable::getEntityReference public function Return the target of an entityreference field.
HostingFieldable::getFieldValue public function Return the value of a field.
HostingFieldable::getFieldValueType public function
HostingFieldable::setEntityReference public function Return the target of an entityreference field.
HostingFieldable::setFieldValue public function Set the value of a field.
HostingFieldable::setProperty public function Set the value of a property.
HostingNode::$info_fields protected property
HostingNode::$node protected property
HostingNode::fixNodeFieldDisplay public function Display a field as an Aegir-themed 'info' item.
HostingNode::getInfoFields protected function
HostingNode::getLanguage public function
HostingNode::getNid public function
HostingNode::getNode public function
HostingNode::getTitle public function
HostingNode::nodeView public function Alter the display of a node.
HostingNode::save public function Save the node.
HostingNode::__construct function