lithium\data\DocumentSchema::cast PHP Method

cast() public method

public cast ( $object, $key, $data, array $options = [] )
$options array
    public function cast($object, $key, $data, array $options = array())
    {
        $defaults = array('parent' => null, 'pathKey' => null, 'model' => null, 'wrap' => true, 'asContent' => false, 'first' => false);
        $options += $defaults;
        $basePathKey = $options['pathKey'];
        $classes = $this->_classes;
        $fieldName = is_int($key) ? null : $key;
        $pathKey = $basePathKey;
        if ($fieldName) {
            $pathKey = $basePathKey ? "{$basePathKey}.{$fieldName}" : $fieldName;
        }
        if ($data instanceof $classes['set'] || $data instanceof $classes['entity']) {
            return $data;
        }
        if (is_object($data) && !$this->is('array', $pathKey) && !$options['asContent']) {
            return $data;
        }
        return $this->_castArray($object, $data, $pathKey, $options, $defaults);
    }