We will follow the same approach as the last chapter to add this functionality. We will also need to create a new table in the database to add the link information. As usual, when we create a new table we should also create the table gateway that we will use to access the data. Finally, we need to create a new method that will be linked up inside the create()
method and will be called based on the data inside the request.
The requirements for this functionality will not change in terms of the HTTP methods we are exposing right now. The only difference is that now the create()
method will check for a new key inside the $data
array. If found, we will execute another specialized method called
createLink()
that will visit the web page, extract the data we want, and store it in the database. Finally, we will need to create a custom validator that we will re-use on the client code in order to validate a URL.