Forma de instancia de Zend_Db_Table_Row Zend_Auth

yo suelo Zend_Auth y Zend_Auth_Adapter_DbTable in my project. I want to get a Zend_Db_Table_Row instancia de la Zend_Auth adapter (Zend_Auth_Adapter_DbTable). I haven't found any good solution. I need a Zend_Db_Table_Row instance because I use own row class in which I have a method to get data from dependent table.

I know that I can get this data once again but it makes no sense because this data was already fetched from the database by Zend_Auth_Adapter_DbTable.

preguntado el 10 de marzo de 12 a las 13:03

2 Respuestas

The trick is putting the row into a Zend_Auth_Storage container. By overriding Zend_Auth_Adapter_Interface::authenticate(), you can do just that.

/**
 * Authenticate
 *
 * Overriding to provide more information about the authenticated user
 *
 * @return Zend_Auth_Result
 */
public function authenticate()
{
    $result = parent::authenticate();

    //  Store row on success
    if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
        return new Zend_Auth_Result(
            $result->getCode(),
            $this->getResultRowObject(null, array('*')),
            $result->getMessages()
        );
    } else {
        return $result;
    }
}

Respondido 11 Abr '12, 02:04

Zend_Auth_Adapter_DbTable fetches only those fields, which stored in users table (getResultRowObject()). I think it's more expedient is instancing your Row class (or User class) with data provided by Zend_Auth_Adapter_DbTable

Look here for similar question: En Zend_Auth, ¿puedo obtener un objeto de usuario de modelo de dominio en lugar de stdClass?

contestado el 23 de mayo de 17 a las 11:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.