src/Charcoal/Source/DatabaseSource.php
private function getModelFields(ModelInterface $model, $properties = null)
    {
        if ($properties === null) {
            // No custom properties; use all (from model metadata)
            $properties = array_keys($model->metadata()->properties());
        } else {
            // Ensure the key is always in the required fields.
            $properties = array_unique(array_merge([ $model->key() ], $properties));
        }

        $fields = [];
        foreach ($properties as $propertyIdent) {
            $prop = $model->property($propertyIdent);
            if (!$prop || !$prop->active() || !$prop->storable()) {
                continue;
            }

            $val = $model->propertyValue($propertyIdent);
            foreach ($prop->fields($val) as $fieldIdent => $field) {
                $fields[$field->ident()] = $field;
            }
        }

        return $fields;
    }
private function getModelFields(ModelInterface $model, $properties = null)
    {
        if ($properties === null) {
            // No custom properties; use all (from model metadata)
            $properties = array_keys($model->metadata()->properties());
        } else {
            // Ensure the key is always in the required fields.
            $properties = array_unique(array_merge([ $model->key() ], $properties));
        }

        $fields = [];
        foreach ($properties as $propertyIdent) {
            $prop = $model->property($propertyIdent);
            if (!$prop || !$prop->active() || !$prop->storable()) {
                continue;
            }

            $val = $model->propertyValue($propertyIdent);
            foreach ($prop->fields($val) as $fieldIdent => $field) {
                $fields[$field->ident()] = $field;
            }
        }

        return $fields;
    }
private function getModelFields ( ModelInterface $ model , $ properties = null ) { if ( $ properties === null ) { // No custom properties; use all (from model metadata) $ properties = array_keys ( $ model -> metadata ( ) -> properties ( ) ) ; } else { // Ensure the key is always in the required fields. $ properties = array_unique ( array_merge ( [ $ model -> key ( ) ] , $ properties ) ) ; } $ fields = [ ] ; foreach ( $ properties as $ propertyIdent ) { $ prop = $ model -> property ( $ propertyIdent ) ; if ( ! $ prop || ! $ prop -> active ( ) || ! $ prop -> storable ( ) ) { continue ; } $ val = $ model -> propertyValue ( $ propertyIdent ) ; foreach ( $ prop -> fields ( $ val ) as $ fieldIdent => $ field ) { $ fields [ $ field -> ident ( ) ] = $ field ; } } return $ fields ; }
Retrieve all fields from a model.

@todo   Move this method in StorableTrait or AbstractModel
@param  ModelInterface $model      The model to get fields from.
@param  array|null     $properties Optional list of properties to get.
If NULL, retrieve all (from metadata).
@return PropertyField[]
Retrieve all fields from a model .