src/CRUDlex/UserSetup.php
public function addEvents(AbstractData $data, $passwordField = 'password', $saltField = 'salt')
    {

        $that = $this;
        $saltGenFunction = function(Entity $entity) use ($saltField, $that) {
            $salt = $that->getSalt(40);
            $entity->set($saltField, $salt);
            return true;
        };

        $data->getEvents()->push('before', 'create', $saltGenFunction);

        $pwHashFunction = $this->getPWHashFunction($data, $passwordField, $saltField);

        $data->getEvents()->push('before', 'create', $pwHashFunction);
        $data->getEvents()->push('before', 'update', $pwHashFunction);

    }
public function addEvents(AbstractData $data, $passwordField = 'password', $saltField = 'salt')
    {

        $that = $this;
        $saltGenFunction = function(Entity $entity) use ($saltField, $that) {
            $salt = $that->getSalt(40);
            $entity->set($saltField, $salt);
            return true;
        };

        $data->getEvents()->push('before', 'create', $saltGenFunction);

        $pwHashFunction = $this->getPWHashFunction($data, $passwordField, $saltField);

        $data->getEvents()->push('before', 'create', $pwHashFunction);
        $data->getEvents()->push('before', 'update', $pwHashFunction);

    }
public function addEvents ( AbstractData $ data , $ passwordField = 'password' , $ saltField = 'salt' ) { $ that = $ this ; $ saltGenFunction = function ( Entity $ entity ) use ( $ saltField , $ that ) { $ salt = $ that -> getSalt ( 40 ) ; $ entity -> set ( $ saltField , $ salt ) ; return true ; } ; $ data -> getEvents ( ) -> push ( 'before' , 'create' , $ saltGenFunction ) ; $ pwHashFunction = $ this -> getPWHashFunction ( $ data , $ passwordField , $ saltField ) ; $ data -> getEvents ( ) -> push ( 'before' , 'create' , $ pwHashFunction ) ; $ data -> getEvents ( ) -> push ( 'before' , 'update' , $ pwHashFunction ) ; }
Setups CRUDlex with some events so the passwords get salted and
hashed properly.

@param AbstractData $data
the AbstractData instance managing the users

@param string $passwordField
the Entity fieldname of the password hash

@param string $saltField
the Entity fieldname of the password hash salt
Setups CRUDlex with some events so the passwords get salted and hashed properly .