Newscoop\Entity\User::getRawAttributes PHP Method

getRawAttributes() public method

Get raw user attributes
public getRawAttributes ( ) : array
return array
    public function getRawAttributes()
    {
        $attributes = array();
        foreach ($this->attributes->getKeys() as $key) {
            $attributes[$key] = $this->attributes[$key]->getValue();
        }
        return $attributes;
    }

Usage Example

 /**
  * Add user attributes subform to form
  *
  * @param  Zend_Form            $form
  * @param  Newscoop\Entity\User $user
  * @return void
  */
 private function addUserAttributesSubForm(Zend_Form $form, User $user)
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $subForm = new Zend_Form_SubForm();
     $subForm->setLegend($translator->trans('User attributes', array(), 'users'));
     foreach ($user->getRawAttributes() as $key => $val) {
         $subForm->addElement('text', $key, array('label' => $key));
     }
     $subForm->setDefaults($user->getAttributes());
     $form->addSubForm($subForm, 'attributes');
 }