-
Notifications
You must be signed in to change notification settings - Fork 333
Description
I've combined proposed changes to the forms and service layer into one as the latter depends heavily on the former. This one actually is an RFC as I haven't implemented a prototype yet.
Service Layer
We can simplify the service layer by pushing concerns such as the object being hydrated/extracted and password hashing on save -- both of which the service currently handles -- out of the service layer.
- CreateUserForm can instantiate an empty instance of the user class itself
- Password hashing can be performed by the hydrator when required
Q: Putting the password hasing in the hydrator might be an ill-conceived idea. Any better ideas that avoid having the hashing hard-coded into the service? I just don't like it in the service...it should be part of the form handling process. A filter, maybe?
interface UserServiceInterface
{
/**
* @return UserEntityInterface
* @throws RuntimeException on failure to create user
*/
public function create(array $data);
/**
* @return UserEntityInterface
* @throws RuntimeException on failure to update user
*/
public function update(UserEntityInterface $user, array $data);
/**
* @return UserEntityInterface
* @throws RuntimeException on failure to delete user
*/
public function delete(UserEntityInterface $user);
// Convenience; proxy directly to mapper methods
public function findById($value);
public function findByUsername($value);
public function findByEmail($value);
}
Q: Proxy
find*methods through to mapper, or just provide a getter for the mapper as the current service does? My preference is on proxying the methods so we're not forcing userland code to reach through the service to get at the mapper to run a query.
A class implementing this interface would require three dependencies
- Mapper instance
- CreateUserForm instance
- UpdateUserForm instance
NOTE: CreateUserForm and UpdateUserForm are instances of the same class (UserForm). They are created separately by the FormElementManager so that modules extending ZfcUser could attach custom fields differentially based on the action occurring.
Form Layer
The login form and input filter would remain largely unchanged except for some updates now that we're away from PHP 5.3.x. The registration form and input filter will evolve to work for both create and update operations:
UserForm (formerly BaseForm)
In terms of elements it will be unchanged.
Q: Should we drop the CAPTCHA? IMO it shouldn't be baked in as not every application needs/wants it. Consuming app can always pull the form and inject the CAPTCHA if they need it.
UserInputFilter (formerly RegisterFilter)
In terms of elements it will be unchanged.
The RecordExists and NoRecordExists validators should be updated to use the context argument so that they work for both create and update operations.
Q: Do we need both? RecordExists isn't actually used by ZfcUser.
Q: Should the validators be changed to allow calling arbitrary mapper methods, like the new authentication layer does?