You are here

private function EntityType::recordFieldChange in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.classes.inc \EntityType::recordFieldChange()

Keep track of changes happening to the entity type.

This is useful to later replica the changes on the DB.

2 calls to EntityType::recordFieldChange()
EntityType::addProperty in ./eck.classes.inc
Add a new property to the entity type.
EntityType::removeProperty in ./eck.classes.inc
Remove a property.

File

./eck.classes.inc, line 349
Classes for all the different objects used in ECK.

Class

EntityType
An entity type database object.

Code

private function recordFieldChange($op, $name) {

  // If it is not new we need to keep track of stuff.
  if (!$this->isNew) {
    $p = $this->properties;
    $c = $this->changes;
    switch ($op) {
      case 'add':

        // If the property does not exist already add keep track.
        if (!array_key_exists($name, $p)) {
          $c[$op][] = $name;
        }
        break;
      case 'remove':

        // If there is an add in the changes take it out, otherwise add a
        // remove.
        if (array_key_exists('add', $c)) {
          $key = array_search($name, $c['add']);
          if ($key != FALSE) {
            unset($c['add'][$key]);
          }
        }
        else {
          $c[$op][] = $name;
        }
        break;
    }
    $this->changes = $c;
  }
}