RoadtripsController
extends AppController
in package
Roadtrips Controller
Table of Contents
Properties
Methods
- add() : Response|null|void
- Add method Creates a new roadtrip.
- beforeFilter() : void
- beforeFilter callback.
- beforeRender() : mixed
- delete() : Response|null
- Delete method
- deleteHistory() : Response|null
- Deletes all history records for the current user.
- edit() : Response|null|void
- Edit method Modifies an existing roadtrip.
- exportGpx() : Response|null
- Exports a roadtrip as a GPX file.
- exportPdf() : Response|null
- Exports a roadtrip as a PDF file.
- getFavoritePlaces() : Response
- Retrieves the connected user's favorite places for the map.
- history() : Response|null|void
- History method Displays the roadtrips visited by the user.
- index() : Response|null|void
- Index method Displays public roadtrips and random featured roadtrips.
- initialize() : void
- Initialization hook method.
- myRoadtrips() : Response|null|void
- Displays the connected user's roadtrips.
- publicRoadtrips() : Response|null|void
- Displays all public roadtrips.
- share() : Response|null
- Generates a sharing link for a roadtrip.
- uploadStepImage() : Response
- Uploads an image for a sub-step via AJAX.
- view() : Response|null|void
- View method Displays details of a specific roadtrip.
- _getCoordinates() : array<string|int, mixed>|null
- Retrieves coordinates for a given city name via DB cache or Nominatim API.
- _formatTripsForJs() : array<string|int, mixed>
- Formats trips entities for JavaScript map rendering.
- _mapJsonToCakeEntities() : array<string|int, mixed>
- Maps raw JSON string from frontend to CakePHP entity format.
Properties
$Roadtrips
public
RoadtripsTable
$Roadtrips
Methods
add()
Add method Creates a new roadtrip.
public
add() : Response|null|void
Return values
Response|null|void —Redirects on successful add, renders view otherwise.
beforeFilter()
beforeFilter callback.
public
beforeFilter(EventInterface $event) : void
Allows unauthenticated users to access specific actions.
Parameters
- $event : EventInterface
-
An Event instance
beforeRender()
public
beforeRender(EventInterface $event) : mixed
Parameters
- $event : EventInterface
delete()
Delete method
public
delete([string|null $id = null ]) : Response|null
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|null —Redirects to myRoadtrips.
deleteHistory()
Deletes all history records for the current user.
public
deleteHistory() : Response|null
Return values
Response|null —Redirects to history.
edit()
Edit method Modifies an existing roadtrip.
public
edit([string|null $id = null ]) : Response|null|void
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|null|void —Redirects on successful edit, renders view otherwise.
exportGpx()
Exports a roadtrip as a GPX file.
public
exportGpx([string|null $id = null ]) : Response|null
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|nullexportPdf()
Exports a roadtrip as a PDF file.
public
exportPdf([string|null $id = null ]) : Response|null
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|nullgetFavoritePlaces()
Retrieves the connected user's favorite places for the map.
public
getFavoritePlaces() : Response
Return values
Response —JSON response containing favorite places
history()
History method Displays the roadtrips visited by the user.
public
history() : Response|null|void
Return values
Response|null|void —Renders view
index()
Index method Displays public roadtrips and random featured roadtrips.
public
index() : Response|null|void
Return values
Response|null|void —Renders view
initialize()
Initialization hook method.
public
initialize() : void
myRoadtrips()
Displays the connected user's roadtrips.
public
myRoadtrips() : Response|null|void
Return values
Response|null|void —Renders view
publicRoadtrips()
Displays all public roadtrips.
public
publicRoadtrips() : Response|null|void
Return values
Response|null|void —Renders view
share()
Generates a sharing link for a roadtrip.
public
share([string|null $id = null ]) : Response|null
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|null —Redirects back to myRoadtrips with share url.
uploadStepImage()
Uploads an image for a sub-step via AJAX.
public
uploadStepImage() : Response
Return values
Response —JSON response with the image URL.
view()
View method Displays details of a specific roadtrip.
public
view([string|null $id = null ]) : Response|null|void
Parameters
- $id : string|null = null
-
Roadtrip id.
Return values
Response|null|void —Renders view
_getCoordinates()
Retrieves coordinates for a given city name via DB cache or Nominatim API.
protected
_getCoordinates(string $cityName, Table $table) : array<string|int, mixed>|null
Parameters
- $cityName : string
-
The name of the city.
- $table : Table
-
The GeocodedPlaces table instance.
Return values
array<string|int, mixed>|null —Array with 'lat' and 'lon', or null if not found.
_formatTripsForJs()
Formats trips entities for JavaScript map rendering.
private
_formatTripsForJs(iterable<string|int, mixed> $trips) : array<string|int, mixed>
Parameters
- $trips : iterable<string|int, mixed>
-
The trips to format.
Return values
array<string|int, mixed>_mapJsonToCakeEntities()
Maps raw JSON string from frontend to CakePHP entity format.
private
_mapJsonToCakeEntities(string $jsonString) : array<string|int, mixed>
Parameters
- $jsonString : string
-
The JSON string representing trips.
Return values
array<string|int, mixed> —Array formatted for CakePHP entities.