public static function ClosureExpressionVisitor::getObjectFieldValue

Access the field of a given object. This field has to be public directly or indirectly (through an accessor get* or a magic method, __get, __call).

is*() is not supported.

Return value

mixed

2 calls to ClosureExpressionVisitor::getObjectFieldValue()

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php, line 41

Class

ClosureExpressionVisitor
Walks an expression graph and turns it into a PHP closure.

Namespace

Doctrine\Common\Collections\Expr

Code

public static function getObjectFieldValue($object, $field) {
  $accessor = "get" . $field;
  if (method_exists($object, $accessor) || method_exists($object, '__call')) {
    return $object
      ->{$accessor}();
  }
  if ($object instanceof \ArrayAccess) {
    return $object[$field];
  }
  return $object->{$field};
}