redireccion basica
This commit is contained in:
65
app/controllers/RedirectionController.php
Normal file
65
app/controllers/RedirectionController.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use flight\Engine;
|
||||
|
||||
class RedirectionController {
|
||||
|
||||
protected Engine $app;
|
||||
|
||||
public function __construct($app) {
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function redirect( string $path)
|
||||
{
|
||||
$data = $this->getRedirections();
|
||||
$path_lower = strtolower($path);
|
||||
|
||||
if (array_key_exists($path_lower, $data)) {
|
||||
$data = $data[$path_lower];
|
||||
$website = $this->app->get('is_apple') ? $data['website1'] : $data['website2'];
|
||||
|
||||
if (!empty($website)) {
|
||||
$this->app->redirect($website);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Fallback if path not found or website1 is empty
|
||||
$this->app->redirect('https://google.com/maps');
|
||||
}
|
||||
|
||||
public function getRedirections() {
|
||||
|
||||
$data = [
|
||||
'malecon' => [
|
||||
'website1' => 'https://maps.apple/p/-ezVTdQ8aSUs.n',
|
||||
'website2' => 'https://maps.app.goo.gl/n1betgNTZgx4RoEJ8'
|
||||
],
|
||||
'puntacerritos' => [
|
||||
'website1' => '',
|
||||
'website2' => 'https://maps.app.goo.gl/NSDoQZXnFWDcEgor5'
|
||||
],
|
||||
'zonadorada' => [
|
||||
'website1' => '',
|
||||
'website2' => 'https://maps.app.goo.gl/CDt7vRw2M6oEqgBA8'
|
||||
],
|
||||
'galeron' => [
|
||||
'website1' => '',
|
||||
'website2' => 'https://maps.app.goo.gl/CjkXvvNd2aA4ftiKA'
|
||||
],
|
||||
'monosbichis' => [
|
||||
'website1' => '',
|
||||
'website2' => 'https://maps.app.goo.gl/M1dHZoRANfgCH9f67'
|
||||
],
|
||||
'pinchisplebes' => [
|
||||
'website1' => '',
|
||||
'website2' => 'https://maps.app.goo.gl/o2uq6qQQiLxAkw7f6'
|
||||
]
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user