PresenterInterface interface

Framework\Routing\PresenterInterface

Interface PresenterInterface.

The interface for data management via a Web Browser UI
using the HTTP GET and POST methods.

Note: If a presenter needs more than one parameter to get URL path information
provided by placeholders, in addition to $id, do not implement this interface.
But this interface can be a reference because its method names are used in
{@see RouteCollection::presenter()}.

Defined in libraries/routing/src/PresenterInterface.php

Methods #

create()
Handles a POST request for /.
delete()
Handles a POST request for /$id/delete.
edit()
Handles a GET request for /$id/edit.
index()
Handles a GET request for /.
new()
Handles a GET request for /new.
remove()
Handles a GET request for /$id/remove.
show()
Handles a GET request for /$id.
update()
Handles a POST request for /$id/update.

create()

public function create(): mixed

Handles a POST request for /.

Common usage: Try to create a new item. On success, redirect to the 'show' or
'edit' method URL. On fail, back to the 'new' method URL.

Returns mixed

delete()

public function delete(string $id): mixed

Handles a POST request for /$id/delete.

Common usage: Try to delete an item based on the $id. On success, go to the
'index' method URL and show a success message. On fail, back to the 'remove'
method URL and show the error message.

Parameters
  • string $id
Returns mixed

edit()

public function edit(string $id): mixed

Handles a GET request for /$id/edit.

Common usage: Show a form to edit a specific item based on the $id.
The POST action must go to the 'update' method URL.

Parameters
  • string $id
Returns mixed

index()

public function index(): mixed

Handles a GET request for /.

Common usage: Show a list of paginated items.

Returns mixed

new()

public function new(): mixed

Handles a GET request for /new.

Common usage: Show a form with inputs to create a new item.
The POST action must go to the 'create' method URL.

Returns mixed

remove()

public function remove(string $id): mixed

Handles a GET request for /$id/remove.

Common usage: Show an alert message about the item to be deleted based on the
$id. The confirmation action must call a POST request to the 'delete'
method URL.

Parameters
  • string $id
Returns mixed

show()

public function show(string $id): mixed

Handles a GET request for /$id.

Common usage: Show a specific item based on the $id.

Parameters
  • string $id
Returns mixed

update()

public function update(string $id): mixed

Handles a POST request for /$id/update.

Common usage: Try to update an item based on the $id. After the process, back
to the 'edit' method URL and show a message.

Parameters
  • string $id
Returns mixed