O'Reilly logo

Professional PHP Design Patterns by Aaron Saray

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.2. Designing User Interaction

Now that the core has been designed, the next section can be architected. The user interaction section will be a set of modules to provide an interface to the user. The interactions that are needed are:

  • Authentication/authorization

  • Creating, editing, deleting users

  • Providing admin access to all users

21.2.1. Authentication and Authorization

When users access the first page of the site, there are two possible outcomes (Figure 21-3). If they are authenticated, they will see a listing of their contacts. If they are not authenticated, they will be redirected to a login page.

Figure 21-3. Figure 21-3

The IndexModule object will be an instance of the Module that I detailed in the core section. It has one public method, called default(), which is the action that the Controller object would execute during a call to render(). This method needs to make a decision whether to show a collection of contacts or to do the redirect.

Logically, I'm going to assume that the next step is to provide the login view for the user. (I'll discuss contactscollection later, but suffice it to say it's used if the current user is already authenticated.)

Login functionality will be provided by a module (Figure 21-4).

Figure 21-4. Figure 21-4

LoginModule has two public methods. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required