src/Oss2/Doctrine2/WithPreferences.php
public function getIndexedPreference( $name, $withIndex = false, $ignoreExpired = true )
    {
        $values = [];

        foreach( $this->getPreferences() as $pref )
        {
            if( $pref->getName() == $name )
            {
                if( $ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
                    continue;

                if( $withIndex )
                    $values[ $pref->getIx() ] = [ 'index' => $pref->getIx(), 'value' => $pref->getValue() ];
                else
                    $values[ $pref->getIx() ] = $pref->getValue();
            }
        }

        ksort( $values, SORT_NUMERIC );

        return $values;
    }
public function getIndexedPreference( $name, $withIndex = false, $ignoreExpired = true )
    {
        $values = [];

        foreach( $this->getPreferences() as $pref )
        {
            if( $pref->getName() == $name )
            {
                if( $ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
                    continue;

                if( $withIndex )
                    $values[ $pref->getIx() ] = [ 'index' => $pref->getIx(), 'value' => $pref->getValue() ];
                else
                    $values[ $pref->getIx() ] = $pref->getValue();
            }
        }

        ksort( $values, SORT_NUMERIC );

        return $values;
    }
public function getIndexedPreference ( $ name , $ withIndex = false , $ ignoreExpired = true ) { $ values = [ ] ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( $ pref -> getName ( ) == $ name ) { if ( $ ignoreExpired && $ pref -> getExpiresAt ( ) && ( $ pref -> getExpiresAt ( ) < new \ DateTime ( ) ) ) continue ; if ( $ withIndex ) $ values [ $ pref -> getIx ( ) ] = [ 'index' => $ pref -> getIx ( ) , 'value' => $ pref -> getValue ( ) ] ; else $ values [ $ pref -> getIx ( ) ] = $ pref -> getValue ( ) ; } } ksort ( $ values , SORT_NUMERIC ) ; return $ values ; }
Get indexed preferences as an array

The standard response is an array of scalar values such as:

[ 'a', 'b', 'c' ];

If $withIndex is set to true, then it will be an array of associated arrays with the
index included:

[
[ 'p_index' => '0', 'p_value' => 'a' ],
[ 'p_index' => '1', 'p_value' => 'b' ],
[ 'p_index' => '2', 'p_value' => 'c' ]
);

@param string $name The attribute to load
@param boolean $withIndex default false Include index values.
@param boolean $ignoreExpired If set to false, include expired preferences
@return array an empty array if no such preference(s) exist
Get indexed preferences as an array