You are here

protected function SocialContent::getDynamicProperty in Social Content 7.2

Get the value of a nested property, providing array of property names.

Parameters

object $row: The object to traverse into.

array $attributes: properties to traverse.

Return value

mixed FALSE on error or the property value.

1 call to SocialContent::getDynamicProperty()
SocialContent::attachFields in ./social_content.class.inc
Attach declare fields onto wrapper.

File

./social_content.class.inc, line 1090
Social Content class.

Class

SocialContent
TODO: Table names should be a property for ease of change Separate this class into smaller classes.

Code

protected function getDynamicProperty($row, $attributes) {

  // Remove only NULL values.
  $attributes = array_filter($attributes, 'strlen');
  $success = TRUE;
  $object = (array) $row;
  foreach ($attributes as $attr) {
    if (isset($object[$attr])) {

      // Convert objects to array else leave alone.
      $object = is_object($object[$attr]) ? (array) $object[$attr] : $object[$attr];
    }
    else {
      $success = FALSE;
      break;
    }
  }
  return $success ? $object : FALSE;
}