Cake\ElasticSearch\View\Form\DocumentContext::getProp PHP Method

getProp() protected method

Read property values or traverse arrays/iterators.
protected getProp ( mixed $target, string $field ) : mixed
$target mixed The entity/array/collection to fetch $field from.
$field string The next field to fetch.
return mixed
    protected function getProp($target, $field)
    {
        if (is_array($target) && isset($target[$field])) {
            return $target[$field];
        }
        if ($target instanceof Document) {
            return $target->get($field);
        }
        if ($target instanceof Traversable) {
            foreach ($target as $i => $val) {
                if ($i == $field) {
                    return $val;
                }
            }
            return false;
        }
    }