src/Oss2/Doctrine2/WithPreferences.php
public function getAssocPreference( $name, $index = null, $ignoreExpired = true )
    {
        $values = [];

        foreach( $this->getPreferences() as $pref )
        {
            if( strpos( $pref->getName(), $name ) === 0 )
            {
                if( ( $index === null ) || ( $pref->getIx() == $index ) )
                {
                    if( !$ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
                        continue;

                    if( strpos( $pref->getName(), '.' ) !== false )
                        $key = substr( $pref->getName(), strlen( $name ) + 1 );

                    if( $key )
                    {
                        $key = $pref->getIx() . '.' . $key;
                        $values = $this->_processKey( $values, $key, $pref->getValue() );
                    }
                    else
                    {
                        $values[ $pref->getIx() ] = $pref->getValue();
                    }
                }
            }
        }

        if( $values === [] )
            return false;

        return $values;
    }
public function getAssocPreference( $name, $index = null, $ignoreExpired = true )
    {
        $values = [];

        foreach( $this->getPreferences() as $pref )
        {
            if( strpos( $pref->getName(), $name ) === 0 )
            {
                if( ( $index === null ) || ( $pref->getIx() == $index ) )
                {
                    if( !$ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
                        continue;

                    if( strpos( $pref->getName(), '.' ) !== false )
                        $key = substr( $pref->getName(), strlen( $name ) + 1 );

                    if( $key )
                    {
                        $key = $pref->getIx() . '.' . $key;
                        $values = $this->_processKey( $values, $key, $pref->getValue() );
                    }
                    else
                    {
                        $values[ $pref->getIx() ] = $pref->getValue();
                    }
                }
            }
        }

        if( $values === [] )
            return false;

        return $values;
    }
public function getAssocPreference ( $ name , $ index = null , $ ignoreExpired = true ) { $ values = [ ] ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( strpos ( $ pref -> getName ( ) , $ name ) === 0 ) { if ( ( $ index === null ) || ( $ pref -> getIx ( ) == $ index ) ) { if ( ! $ ignoreExpired && $ pref -> getExpiresAt ( ) && ( $ pref -> getExpiresAt ( ) < new \ DateTime ( ) ) ) continue ; if ( strpos ( $ pref -> getName ( ) , '.' ) !== false ) $ key = substr ( $ pref -> getName ( ) , strlen ( $ name ) + 1 ) ; if ( $ key ) { $ key = $ pref -> getIx ( ) . '.' . $ key ; $ values = $ this -> _processKey ( $ values , $ key , $ pref -> getValue ( ) ) ; } else { $ values [ $ pref -> getIx ( ) ] = $ pref -> getValue ( ) ; } } } } if ( $ values === [ ] ) return false ; return $ values ; }
Get associative preferences as an array.

For example, if we have preferences:

attribute email.address   idx=0 value=1email
attribute email.confirmed idx=0 value=false
attribute email.tokens.0  idx=0 value=fwfddwde
attribute email.tokens.1  idx=0 value=fwewec4r
attribute email.address   idx=1 value=2email
attribute email.confirmed idx=1 value=true

and if we search by `$name = 'email'` we will get:

[
0 => [
'address' => '1email',
'confirmed' => false,
'tokens' => [
0 => 'fwfddwde',
1 => 'fwewec4r'
]
],

1 => [
'address' => '2email',
'confirmed' => true
]
]


@param string $name The attribute to load
@param int $index default null If an indexed preference, get a specific index, null means all indexes alowed
@param boolean $ignoreExpired default true If set to false, then includes expired preferences
@return boolean|array False if no such preference(s) exist, otherwise an array.
Get associative preferences as an array .