Swat/SwatCellRendererSet.php
public function applyMappingsToRenderer(
        SwatCellRenderer $renderer,
        $data_object
    ) {
        // array to track array properties that we've already seen
        $array_properties = array();

        $renderer_hash = spl_object_hash($renderer);
        foreach ($this->mappings[$renderer_hash] as $mapping) {
            // set local variables
            $property = $mapping->property;
            $field = $mapping->field;

            if ($mapping->is_array) {
                if (in_array($property, $array_properties)) {
                    // already have an array
                    $array_ref = &$renderer->$property;

                    if ($mapping->array_key === null) {
                        $array_ref[] = $data_object->$field;
                    } else {
                        $array_ref[$mapping->array_key] = $data_object->$field;
                    }
                } else {
                    // starting a new array
                    $array_properties[] = $mapping->property;

                    if ($mapping->array_key === null) {
                        $renderer->$property = array($data_object->$field);
                    } else {
                        $renderer->$property = array(
                            $mapping->array_key => $data_object->$field
                        );
                    }
                }
            } else {
                // look for leading '!' and inverse value if found
                if (strncmp($field, '!', 1) === 0) {
                    $field = mb_substr($field, 1);
                    $renderer->$property = !$data_object->$field;
                } else {
                    $renderer->$property = $data_object->$field;
                }
            }
        }

        $this->mappings_applied = true;
    }
public function applyMappingsToRenderer(
        SwatCellRenderer $renderer,
        $data_object
    ) {
        // array to track array properties that we've already seen
        $array_properties = array();

        $renderer_hash = spl_object_hash($renderer);
        foreach ($this->mappings[$renderer_hash] as $mapping) {
            // set local variables
            $property = $mapping->property;
            $field = $mapping->field;

            if ($mapping->is_array) {
                if (in_array($property, $array_properties)) {
                    // already have an array
                    $array_ref = &$renderer->$property;

                    if ($mapping->array_key === null) {
                        $array_ref[] = $data_object->$field;
                    } else {
                        $array_ref[$mapping->array_key] = $data_object->$field;
                    }
                } else {
                    // starting a new array
                    $array_properties[] = $mapping->property;

                    if ($mapping->array_key === null) {
                        $renderer->$property = array($data_object->$field);
                    } else {
                        $renderer->$property = array(
                            $mapping->array_key => $data_object->$field
                        );
                    }
                }
            } else {
                // look for leading '!' and inverse value if found
                if (strncmp($field, '!', 1) === 0) {
                    $field = mb_substr($field, 1);
                    $renderer->$property = !$data_object->$field;
                } else {
                    $renderer->$property = $data_object->$field;
                }
            }
        }

        $this->mappings_applied = true;
    }
public function applyMappingsToRenderer ( SwatCellRenderer $ renderer , $ data_object ) { // array to track array properties that we've already seen $ array_properties = array ( ) ; $ renderer_hash = spl_object_hash ( $ renderer ) ; foreach ( $ this -> mappings [ $ renderer_hash ] as $ mapping ) { // set local variables $ property = $ mapping -> property ; $ field = $ mapping -> field ; if ( $ mapping -> is_array ) { if ( in_array ( $ property , $ array_properties ) ) { // already have an array $ array_ref = & $ renderer -> $ property ; if ( $ mapping -> array_key === null ) { $ array_ref [ ] = $ data_object -> $ field ; } else { $ array_ref [ $ mapping -> array_key ] = $ data_object -> $ field ; } } else { // starting a new array $ array_properties [ ] = $ mapping -> property ; if ( $ mapping -> array_key === null ) { $ renderer -> $ property = array ( $ data_object -> $ field ) ; } else { $ renderer -> $ property = array ( $ mapping -> array_key => $ data_object -> $ field ) ; } } } else { // look for leading '!' and inverse value if found if ( strncmp ( $ field , '!' , 1 ) === 0 ) { $ field = mb_substr ( $ field , 1 ) ; $ renderer -> $ property = ! $ data_object -> $ field ; } else { $ renderer -> $ property = $ data_object -> $ field ; } } } $ this -> mappings_applied = true ; }
Applies the property-datafield mappings to a cell renderer already in
this set using a specified data object

@param SwatCellRenderer $renderer the cell renderer to apply the
mappings to.
@param mixed $data_object an object containg datafields to be
mapped onto the cell renderer.
Applies the property - datafield mappings to a cell renderer already in this set using a specified data object