public function exportGettableProperties(array $propertyNameMap = array(), $onlyMappedProperties = false)
    {
        $export = array();
        $propertyNameMap = $this->convertPropertyMap($propertyNameMap);

        // Loop values, skipping mapped properties, use Trait's internal getter to get value.
        // We are suppressing Exceptions in this step in order to not disclose the reason why
        // a particular property could not be read. Possible causes are visibility, typos
        // in getter method name, non-standard getter method naming, or third-party Exceptions
        // being thrown from a getter.
        if (!$onlyMappedProperties) {
            $sourcePropertyNames = array_keys(get_class_vars(get_called_class()));
            foreach ($sourcePropertyNames as $propertyName) {
                if (isset($propertyNameMap[$propertyName]) || $propertyName === 'populatableAccessorMethodNames') {
                    continue;
                }
                try {
                    $export[$propertyName] = $this->getPopulatedProperty($propertyName);
                } catch (Exception $error) {
                    // @TODO: consider logging failures w/ reason
                    continue;
                }
            }
        }

        // loop the mapped properties last to ensure mapping overrides defaults
        foreach ($propertyNameMap as $sourcePropertyName => $targetPropertyName) {
            $export[$targetPropertyName] = $this->getPopulatedProperty($sourcePropertyName);
        }

        return $export;
    }
public function exportGettableProperties(array $propertyNameMap = array(), $onlyMappedProperties = false)
    {
        $export = array();
        $propertyNameMap = $this->convertPropertyMap($propertyNameMap);

        // Loop values, skipping mapped properties, use Trait's internal getter to get value.
        // We are suppressing Exceptions in this step in order to not disclose the reason why
        // a particular property could not be read. Possible causes are visibility, typos
        // in getter method name, non-standard getter method naming, or third-party Exceptions
        // being thrown from a getter.
        if (!$onlyMappedProperties) {
            $sourcePropertyNames = array_keys(get_class_vars(get_called_class()));
            foreach ($sourcePropertyNames as $propertyName) {
                if (isset($propertyNameMap[$propertyName]) || $propertyName === 'populatableAccessorMethodNames') {
                    continue;
                }
                try {
                    $export[$propertyName] = $this->getPopulatedProperty($propertyName);
                } catch (Exception $error) {
                    // @TODO: consider logging failures w/ reason
                    continue;
                }
            }
        }

        // loop the mapped properties last to ensure mapping overrides defaults
        foreach ($propertyNameMap as $sourcePropertyName => $targetPropertyName) {
            $export[$targetPropertyName] = $this->getPopulatedProperty($sourcePropertyName);
        }

        return $export;
    }
public function exportGettableProperties ( array $ propertyNameMap = array ( ) , $ onlyMappedProperties = false ) { $ export = array ( ) ; $ propertyNameMap = $ this -> convertPropertyMap ( $ propertyNameMap ) ; // Loop values, skipping mapped properties, use Trait's internal getter to get value. // We are suppressing Exceptions in this step in order to not disclose the reason why // a particular property could not be read. Possible causes are visibility, typos // in getter method name, non-standard getter method naming, or third-party Exceptions // being thrown from a getter. if ( ! $ onlyMappedProperties ) { $ sourcePropertyNames = array_keys ( get_class_vars ( get_called_class ( ) ) ) ; foreach ( $ sourcePropertyNames as $ propertyName ) { if ( isset ( $ propertyNameMap [ $ propertyName ] ) || $ propertyName === 'populatableAccessorMethodNames' ) { continue ; } try { $ export [ $ propertyName ] = $ this -> getPopulatedProperty ( $ propertyName ) ; } catch ( Exception $ error ) { // @TODO: consider logging failures w/ reason continue ; } } } // loop the mapped properties last to ensure mapping overrides defaults foreach ( $ propertyNameMap as $ sourcePropertyName => $ targetPropertyName ) { $ export [ $ targetPropertyName ] = $ this -> getPopulatedProperty ( $ sourcePropertyName ) ; } return $ export ; }
Exports properties from this object to a plain
array, optionally mapping property names to
array indices using a property name map - and
optionally only exporting those properties whose
names are included in the property name map.

To selectively populate properties without mapping
their names, use a mirror array as property name
map and <code>true</code> as third parameter, e.g.

$object->exportGettableProperties(array('test' => 'test'), true);

This causes $object to be populated using $only the
"test" property from $source.

@param  array   $propertyNameMap Optional array of property names
supporting mapping (see README)
@param  boolean $onlyMappedProperties If <code>true</code> will only populate
properties contained in map
@throws Exception If a property name map is passed and only mapped properties
flag is <code>true</code>, any Exceptions will be passed through because
this is considered an explicit attempt at access. However, if _all_
properties are requested (which happens when the only mapped properties
flag is <code>false</code>), Exceptions are suppressed and erroneous
properties silently ignored and removed from the output array because
in this case, it is likely that the list of property names came from a
source like <code>get_class_vars</code> which does not care about the
presence of getter/setter methods so we must tolerate and skip failures.
Exports properties from this object to a plain array optionally mapping property names to array indices using a property name map - and optionally only exporting those properties whose names are included in the property name map .